<!--
{
  "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/init(upstream:receiveSubscription:receiveOutput:receiveCompletion:receiveCancel:receiveRequest:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine10PublishersO12HandleEventsV8upstream19receiveSubscription0F6Output0F10Completion0F6Cancel0F7RequestAEy_xGx_yAA0G0_pcSgy0H0QzcSgyAA11SubscribersO0I0Oy_7FailureQzGcSgyycSgyAS6DemandVcSgtcfc"
  },
  "title" : "init(upstream:receiveSubscription:receiveOutput:receiveCompletion:receiveCancel:receiveRequest:)"
}
-->

# init(upstream:receiveSubscription:receiveOutput:receiveCompletion:receiveCancel:receiveRequest:)

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

```
init(upstream: Upstream, receiveSubscription: ((any Subscription) -> Void)? = nil, receiveOutput: ((Publishers.HandleEvents<Upstream>.Output) -> Void)? = nil, receiveCompletion: ((Subscribers.Completion<Publishers.HandleEvents<Upstream>.Failure>) -> Void)? = nil, receiveCancel: (() -> Void)? = nil, receiveRequest: ((Subscribers.Demand) -> Void)?)
```

## Parameters

`upstream`

The publisher from which this publisher receives elements.

`receiveSubscription`

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

`receiveOutput`

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

`receiveCompletion`

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

`receiveCancel`

A closure that executes when the downstream receiver cancels publishing.

`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)