<!--
{
  "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/Publisher/sink(receiveValue:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine9PublisherPAAs5NeverO7FailureRtzrlE4sink12receiveValueAA14AnyCancellableCy6OutputQzc_tF"
  },
  "title" : "sink(receiveValue:)"
}
-->

# sink(receiveValue:)

Attaches a subscriber with closure-based behavior to a publisher that never fails.

```
func sink(receiveValue: @escaping (Self.Output) -> Void) -> AnyCancellable
```

## Parameters

`receiveValue`

The closure to execute on receipt of a value.

## Return Value

A cancellable instance, which you use when you end assignment of the received value. Deallocation of the result will tear down the subscription stream.

## Discussion

Use [`sink(receiveValue:)`](/documentation/Combine/Publisher/sink(receiveValue:)) to observe values received by the publisher and print them to the console. This operator can only be used when the stream doesn’t fail, that is, when the publisher’s [`Failure`](/documentation/Combine/Publisher/Failure) type is <doc://com.apple.documentation/documentation/Swift/Never>.

In this example, a <doc://com.apple.documentation/documentation/Swift/Range> publisher publishes integers to a [`sink(receiveValue:)`](/documentation/Combine/Publisher/sink(receiveValue:)) operator’s
`receiveValue` closure that prints them to the console:

```
let integers = (0...3)
integers.publisher
    .sink { print("Received \($0)") }

// Prints:
//  Received 0
//  Received 1
//  Received 2
//  Received 3
```

This method creates the subscriber and immediately requests an unlimited number of values, prior to returning the subscriber.
The return value should be held, otherwise the stream will be canceled.

---

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)