<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Combine",
  "identifier" : "/documentation/Combine/Publishers/HandleEvents",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine10PublishersO12HandleEventsV"
  },
  "title" : "Publishers.HandleEvents"
}
-->

# Publishers.HandleEvents

A publisher that performs the specified closures when publisher events occur.

```
struct HandleEvents<Upstream> where Upstream : Publisher
```

## Topics

### Creating an event-handling publisher

[`init(upstream:receiveSubscription:receiveOutput:receiveCompletion:receiveCancel:receiveRequest:)`](/documentation/Combine/Publishers/HandleEvents/init(upstream:receiveSubscription:receiveOutput:receiveCompletion:receiveCancel:receiveRequest:))

Creates a publisher that performs the specified closures when publisher events occur.

### Declaring supporting types

[`Publishers.HandleEvents.Output`](/documentation/Combine/Publishers/HandleEvents/Output)

The kind of values published by this publisher.

[`Publishers.HandleEvents.Failure`](/documentation/Combine/Publishers/HandleEvents/Failure)

The kind of errors this publisher might publish.

### Inspecting publisher properties

[`upstream`](/documentation/Combine/Publishers/HandleEvents/upstream)

The publisher from which this publisher receives elements.

[`receiveSubscription`](/documentation/Combine/Publishers/HandleEvents/receiveSubscription)

A closure that executes when the publisher receives the subscription from the upstream publisher.

[`receiveOutput`](/documentation/Combine/Publishers/HandleEvents/receiveOutput)

A closure that executes when the publisher receives a value from the upstream publisher.

[`receiveCompletion`](/documentation/Combine/Publishers/HandleEvents/receiveCompletion)

A closure that executes when the upstream publisher finishes normally or terminates with an error.

[`receiveCancel`](/documentation/Combine/Publishers/HandleEvents/receiveCancel)

A closure that executes when the downstream receiver cancels publishing.

[`receiveRequest`](/documentation/Combine/Publishers/HandleEvents/receiveRequest)

A closure that executes when the publisher receives a request for more elements.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)