<!--
{
  "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",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine9PublisherP"
  },
  "title" : "Publisher"
}
-->

# Publisher

Declares that a type can transmit a sequence of values over time.

```
protocol Publisher<Output, Failure>
```

## Overview

A publisher delivers elements to one or more [`Subscriber`](/documentation/Combine/Subscriber) instances.
The subscriber’s [`Input`](/documentation/Combine/Subscriber/Input) and [`Failure`](/documentation/Combine/Subscriber/Failure) associated types must match the [`Output`](/documentation/Combine/Publisher/Output) and [`Failure`](/documentation/Combine/Publisher/Failure) types declared by the publisher.
The publisher implements the [`receive(subscriber:)`](/documentation/Combine/Publisher/receive(subscriber:))method to accept a subscriber.

After this, the publisher can call the following methods on the subscriber:

- [`receive(subscription:)`](/documentation/Combine/Subscriber/receive(subscription:)): Acknowledges the subscribe request and returns a [`Subscription`](/documentation/Combine/Subscription) instance. The subscriber uses the subscription to demand elements from the publisher and can use it to cancel publishing.
- [`receive(_:)`](/documentation/Combine/Subscriber/receive(_:)): Delivers one element from the publisher to the subscriber.
- [`receive(completion:)`](/documentation/Combine/Subscriber/receive(completion:)): Informs the subscriber that publishing has ended, either normally or with an error.

Every `Publisher` must adhere to this contract for downstream subscribers to function correctly.

> Tip: A Combine publisher fills a role similar to, but distinct from, the
> <doc://com.apple.documentation/documentation/Swift/AsyncSequence> in the
> Swift standard library. A `Publisher` and an
> `AsyncSequence` both produce elements over time. However, the pull model in Combine
> uses a ``doc://com.apple.Combine/documentation/Combine/Subscriber`` to request elements from a publisher, while Swift
> concurrency uses the `for`-`await`-`in` syntax to iterate over elements
> published by an `AsyncSequence`. Both APIs offer methods to modify the sequence
> by mapping or filtering elements, while only Combine provides time-based
> operations like
> ``doc://com.apple.Combine/documentation/Combine/Publisher/debounce(for:scheduler:options:)`` and
> ``doc://com.apple.Combine/documentation/Combine/Publisher/throttle(for:scheduler:latest:)``, and combining operations like
> ``doc://com.apple.Combine/documentation/Combine/Publisher/merge(with:)-7fk3a`` and ``doc://com.apple.Combine/documentation/Combine/Publisher/combineLatest(_:_:)-1n30g``.
> To bridge the two approaches, the property ``doc://com.apple.Combine/documentation/Combine/Publisher/values-1dm9r`` exposes
> a publisher’s elements as an `AsyncSequence`, allowing you to iterate over
> them with `for`-`await`-`in` rather than attaching a ``doc://com.apple.Combine/documentation/Combine/Subscriber``.

### Using operators

Extensions on `Publisher` define a wide variety of *operators* that you compose to create sophisticated event-processing chains.
Each operator returns a type that implements the [`Publisher`](/documentation/Combine/Publisher) protocol
Most of these types exist as extensions on the [`Publishers`](/documentation/Combine/Publishers) enumeration.
For example, the [`map(_:)`](/documentation/Combine/Publisher/map(_:)-99evh) operator returns an instance of [`Publishers.Map`](/documentation/Combine/Publishers/Map).

Use operators to assemble a chain of republishers, optionally ending with a subscriber, that processes elements produced by upstream publishers. Each operator creates and configures an instance of a [`Publisher`](/documentation/Combine/Publisher) or [`Subscriber`](/documentation/Combine/Subscriber), and subscribes it to the publisher that you call the method on.

In the following example, a sequence publisher emits the integers 1, 2, 3, 4, and 5. A [`filter(_:)`](/documentation/Combine/Publisher/filter(_:)) operator creates a [`Publishers.Filter`](/documentation/Combine/Publishers/Filter) publisher to only republish even values. A second operator creates a [`Subscribers.Sink`](/documentation/Combine/Subscribers/Sink) subscriber to print out each value received. The sink subscriber automatically subscribes to the filter publisher, at which point the filter publisher subscribes to its upstream publisher, the sequence publisher.

```
let cancellable = [1, 2, 3, 4, 5].publisher
    .filter {
        $0 % 2 == 0
    }
    .sink {
        print ("Even number: \($0)")
    }
// Prints:
// Even number: 2
// Even number: 4
```

## Creating Your Own Publishers

Rather than implementing the `Publisher` protocol yourself, you can create your own publisher by using one of several types provided by the Combine framework:

- Use a concrete subclass of [`Subject`](/documentation/Combine/Subject), such as [`PassthroughSubject`](/documentation/Combine/PassthroughSubject), to publish values on-demand by calling its [`send(_:)`](/documentation/Combine/Subject/send(_:)) method.
- Use a [`CurrentValueSubject`](/documentation/Combine/CurrentValueSubject) to publish whenever you update the subject’s underlying value.
- Add the `@Published` annotation to a property of one of your own types. In doing so, the property gains a publisher that emits an event whenever the property’s value changes. See the [`Published`](/documentation/Combine/Published) type for an example of this approach.

## Topics

### Declaring supporting types

[`Output`](/documentation/Combine/Publisher/Output)

The kind of values published by this publisher.

[`Failure`](/documentation/Combine/Publisher/Failure)

The kind of errors this publisher might publish.

### Working with subscribers

[`receive(subscriber:)`](/documentation/Combine/Publisher/receive(subscriber:))

Attaches the specified subscriber to this publisher.

[`subscribe(_:)`](/documentation/Combine/Publisher/subscribe(_:)-4u8kn)

Attaches the specified subscriber to this publisher.

[`subscribe(_:)`](/documentation/Combine/Publisher/subscribe(_:)-3fk20)

Attaches the specified subject to this publisher.

### Mapping elements

[`map(_:)`](/documentation/Combine/Publisher/map(_:)-99evh)

Transforms all elements from the upstream publisher with a provided closure.

[`tryMap(_:)`](/documentation/Combine/Publisher/tryMap(_:))

Transforms all elements from the upstream publisher with a provided error-throwing closure.

[`mapError(_:)`](/documentation/Combine/Publisher/mapError(_:))

Converts any failure from the upstream publisher into a new error.

[`replaceNil(with:)`](/documentation/Combine/Publisher/replaceNil(with:))

Replaces nil elements in the stream with the provided element.

[`scan(_:_:)`](/documentation/Combine/Publisher/scan(_:_:))

Transforms elements from the upstream publisher by providing the current
element to a closure along with the last value returned by the closure.

[`tryScan(_:_:)`](/documentation/Combine/Publisher/tryScan(_:_:))

Transforms elements from the upstream publisher by providing the current element to an error-throwing closure along with the last value returned by the closure.

[`setFailureType(to:)`](/documentation/Combine/Publisher/setFailureType(to:))

Changes the failure type declared by the upstream publisher.

### Filtering elements

[`filter(_:)`](/documentation/Combine/Publisher/filter(_:))

Republishes all elements that match a provided closure.

[`tryFilter(_:)`](/documentation/Combine/Publisher/tryFilter(_:))

Republishes all elements that match a provided error-throwing closure.

[`compactMap(_:)`](/documentation/Combine/Publisher/compactMap(_:))

Calls a closure with each received element and publishes any returned optional that has a value.

[`tryCompactMap(_:)`](/documentation/Combine/Publisher/tryCompactMap(_:))

Calls an error-throwing closure with each received element and publishes any returned optional that has a value.

[`removeDuplicates()`](/documentation/Combine/Publisher/removeDuplicates())

Publishes only elements that don’t match the previous element.

[`removeDuplicates(by:)`](/documentation/Combine/Publisher/removeDuplicates(by:))

Publishes only elements that don’t match the previous element, as evaluated by a provided closure.

[`tryRemoveDuplicates(by:)`](/documentation/Combine/Publisher/tryRemoveDuplicates(by:))

Publishes only elements that don’t match the previous element, as evaluated by a provided error-throwing closure.

[`replaceEmpty(with:)`](/documentation/Combine/Publisher/replaceEmpty(with:))

Replaces an empty stream with the provided element.

[`replaceError(with:)`](/documentation/Combine/Publisher/replaceError(with:))

Replaces any errors in the stream with the provided element.

### Reducing elements

[`collect()`](/documentation/Combine/Publisher/collect())

Collects all received elements, and emits a single array of the collection when the upstream publisher finishes.

[`collect(_:)`](/documentation/Combine/Publisher/collect(_:))

Collects up to the specified number of elements, and then emits a single array of the collection.

[`collect(_:options:)`](/documentation/Combine/Publisher/collect(_:options:))

Collects elements by a given time-grouping strategy, and emits a single array of the collection.

[`Publishers.TimeGroupingStrategy`](/documentation/Combine/Publishers/TimeGroupingStrategy)

A strategy for collecting received elements.

[`ignoreOutput()`](/documentation/Combine/Publisher/ignoreOutput())

Ignores all upstream elements, but passes along the upstream publisher’s completion state (finished or failed).

[`reduce(_:_:)`](/documentation/Combine/Publisher/reduce(_:_:))

Applies a closure that collects each element of a stream and publishes a final result upon completion.

[`tryReduce(_:_:)`](/documentation/Combine/Publisher/tryReduce(_:_:))

Applies an error-throwing closure that collects each element of a stream and publishes a final result upon completion.

### Applying mathematical operations on elements

[`count()`](/documentation/Combine/Publisher/count())

Publishes the number of elements received from the upstream publisher.

[`max()`](/documentation/Combine/Publisher/max())

Publishes the maximum value received from the upstream publisher, after it finishes.

[`max(by:)`](/documentation/Combine/Publisher/max(by:))

Publishes the maximum value received from the upstream publisher, using the provided ordering closure.

[`tryMax(by:)`](/documentation/Combine/Publisher/tryMax(by:))

Publishes the maximum value received from the upstream publisher, using the provided error-throwing closure to order the items.

[`min()`](/documentation/Combine/Publisher/min())

Publishes the minimum value received from the upstream publisher, after it finishes.

[`min(by:)`](/documentation/Combine/Publisher/min(by:))

Publishes the minimum value received from the upstream publisher, after it finishes.

[`tryMin(by:)`](/documentation/Combine/Publisher/tryMin(by:))

Publishes the minimum value received from the upstream publisher, using the provided error-throwing closure to order the items.

### Applying matching criteria to elements

[`contains(_:)`](/documentation/Combine/Publisher/contains(_:))

Publishes a Boolean value upon receiving an element equal to the argument.

[`contains(where:)`](/documentation/Combine/Publisher/contains(where:))

Publishes a Boolean value upon receiving an element that satisfies the predicate closure.

[`tryContains(where:)`](/documentation/Combine/Publisher/tryContains(where:))

Publishes a Boolean value upon receiving an element that satisfies the throwing predicate closure.

[`allSatisfy(_:)`](/documentation/Combine/Publisher/allSatisfy(_:))

Publishes a single Boolean value that indicates whether all received elements pass a given predicate.

[`tryAllSatisfy(_:)`](/documentation/Combine/Publisher/tryAllSatisfy(_:))

Publishes a single Boolean value that indicates whether all received elements pass a given error-throwing predicate.

### Applying sequence operations to elements

[`drop(untilOutputFrom:)`](/documentation/Combine/Publisher/drop(untilOutputFrom:))

Ignores elements from the upstream publisher until it receives an element from a second publisher.

[`dropFirst(_:)`](/documentation/Combine/Publisher/dropFirst(_:))

Omits the specified number of elements before republishing subsequent elements.

[`drop(while:)`](/documentation/Combine/Publisher/drop(while:))

Omits elements from the upstream publisher until a given closure returns false, before republishing all remaining elements.

[`tryDrop(while:)`](/documentation/Combine/Publisher/tryDrop(while:))

Omits elements from the upstream publisher until an error-throwing closure returns false, before republishing all remaining elements.

[`append(_:)`](/documentation/Combine/Publisher/append(_:)-1qb8d)

Appends a publisher’s output with the specified elements.

[`append(_:)`](/documentation/Combine/Publisher/append(_:)-69sdn)

Appends a publisher’s output with the specified sequence.

[`append(_:)`](/documentation/Combine/Publisher/append(_:)-5yh02)

Appends the output of this publisher with the elements emitted by the given publisher.

[`prepend(_:)`](/documentation/Combine/Publisher/prepend(_:)-7wk5l)

Prefixes a publisher’s output with the specified values.

[`prepend(_:)`](/documentation/Combine/Publisher/prepend(_:)-v9sb)

Prefixes a publisher’s output with the specified sequence.

[`prepend(_:)`](/documentation/Combine/Publisher/prepend(_:)-5dj9c)

Prefixes the output of this publisher with the elements emitted by the given publisher.

[`prefix(_:)`](/documentation/Combine/Publisher/prefix(_:))

Republishes elements up to the specified maximum count.

[`prefix(while:)`](/documentation/Combine/Publisher/prefix(while:))

Republishes elements while a predicate closure indicates publishing should continue.

[`tryPrefix(while:)`](/documentation/Combine/Publisher/tryPrefix(while:))

Republishes elements while an error-throwing predicate closure indicates publishing should continue.

[`prefix(untilOutputFrom:)`](/documentation/Combine/Publisher/prefix(untilOutputFrom:))

Republishes elements until another publisher emits an element.

### Selecting specific elements

[`first()`](/documentation/Combine/Publisher/first())

Publishes the first element of a stream, then finishes.

[`first(where:)`](/documentation/Combine/Publisher/first(where:))

Publishes the first element of a stream to satisfy a predicate closure, then finishes normally.

[`tryFirst(where:)`](/documentation/Combine/Publisher/tryFirst(where:))

Publishes the first element of a stream to satisfy a throwing predicate closure, then finishes normally.

[`last()`](/documentation/Combine/Publisher/last())

Publishes the last element of a stream, after the stream finishes.

[`last(where:)`](/documentation/Combine/Publisher/last(where:))

Publishes the last element of a stream that satisfies a predicate closure, after upstream finishes.

[`tryLast(where:)`](/documentation/Combine/Publisher/tryLast(where:))

Publishes the last element of a stream that satisfies an error-throwing predicate closure, after the stream finishes.

[`output(at:)`](/documentation/Combine/Publisher/output(at:))

Publishes a specific element, indicated by its index in the sequence of published elements.

[`output(in:)`](/documentation/Combine/Publisher/output(in:))

Publishes elements specified by their range in the sequence of published elements.

### Collecting and republishing the latest elements from multiple publishers

[`combineLatest(_:_:)`](/documentation/Combine/Publisher/combineLatest(_:_:)-1n30g)

Subscribes to an additional publisher and invokes a closure upon receiving output from either publisher.

[`combineLatest(_:)`](/documentation/Combine/Publisher/combineLatest(_:))

Subscribes to an additional publisher and publishes a tuple upon receiving output from either publisher.

[`combineLatest(_:_:_:)`](/documentation/Combine/Publisher/combineLatest(_:_:_:)-6ekpz)

Subscribes to two additional publishers and invokes a closure upon receiving output from any of the publishers.

[`combineLatest(_:_:)`](/documentation/Combine/Publisher/combineLatest(_:_:)-5crqg)

Subscribes to two additional publishers and publishes a tuple upon receiving output from any of the publishers.

[`combineLatest(_:_:_:_:)`](/documentation/Combine/Publisher/combineLatest(_:_:_:_:))

Subscribes to three additional publishers and invokes a closure upon receiving output from any of the publishers.

[`combineLatest(_:_:_:)`](/documentation/Combine/Publisher/combineLatest(_:_:_:)-48buc)

Subscribes to three additional publishers and publishes a tuple upon receiving output from any of the publishers.

### Republishing elements from multiple publishers as an interleaved stream

[`merge(with:)`](/documentation/Combine/Publisher/merge(with:)-7fk3a)

Combines elements from this publisher with those from another publisher of the same type, delivering an interleaved sequence of elements.

[`merge(with:)`](/documentation/Combine/Publisher/merge(with:)-7qt71)

Combines elements from this publisher with those from another publisher, delivering an interleaved sequence of elements.

[`merge(with:_:)`](/documentation/Combine/Publisher/merge(with:_:))

Combines elements from this publisher with those from two other publishers, delivering an interleaved sequence of elements.

[`merge(with:_:_:)`](/documentation/Combine/Publisher/merge(with:_:_:))

Combines elements from this publisher with those from three other publishers, delivering an interleaved sequence of elements.

[`merge(with:_:_:_:)`](/documentation/Combine/Publisher/merge(with:_:_:_:))

Combines elements from this publisher with those from four other publishers, delivering an interleaved sequence of elements.

[`merge(with:_:_:_:_:)`](/documentation/Combine/Publisher/merge(with:_:_:_:_:))

Combines elements from this publisher with those from five other publishers, delivering an interleaved sequence of elements.

[`merge(with:_:_:_:_:_:)`](/documentation/Combine/Publisher/merge(with:_:_:_:_:_:))

Combines elements from this publisher with those from six other publishers, delivering an interleaved sequence of elements.

[`merge(with:_:_:_:_:_:_:)`](/documentation/Combine/Publisher/merge(with:_:_:_:_:_:_:))

Combines elements from this publisher with those from seven other publishers, delivering an interleaved sequence of elements.

### Collecting and republishing the oldest unconsumed elements from multiple publishers

[`zip(_:)`](/documentation/Combine/Publisher/zip(_:))

Combines elements from another publisher and deliver pairs of elements as tuples.

[`zip(_:_:)`](/documentation/Combine/Publisher/zip(_:_:)-4xn21)

Combines elements from another publisher and delivers a transformed output.

[`zip(_:_:)`](/documentation/Combine/Publisher/zip(_:_:)-8d7k7)

Combines elements from two other publishers and delivers groups of elements as tuples.

[`zip(_:_:_:)`](/documentation/Combine/Publisher/zip(_:_:_:)-9yqi1)

Combines elements from two other publishers and delivers a transformed output.

[`zip(_:_:_:)`](/documentation/Combine/Publisher/zip(_:_:_:)-16rcy)

Combines elements from three other publishers and delivers groups of elements as tuples.

[`zip(_:_:_:_:)`](/documentation/Combine/Publisher/zip(_:_:_:_:))

Combines elements from three other publishers and delivers a transformed output.

### Republishing elements by subscribing to new publishers

[`flatMap(maxPublishers:_:)`](/documentation/Combine/Publisher/flatMap(maxPublishers:_:)-3k7z5)

Transforms all elements from an upstream publisher into a new publisher up to a maximum number of publishers you specify.

[`flatMap(maxPublishers:_:)`](/documentation/Combine/Publisher/flatMap(maxPublishers:_:)-qxf)

Transforms all elements from an upstream publisher into a new publisher up to a maximum number of publishers you specify.

[`flatMap(maxPublishers:_:)`](/documentation/Combine/Publisher/flatMap(maxPublishers:_:)-hyb0)

Transforms all elements from an upstream publisher into a new publisher up to a maximum number of publishers you specify.

[`flatMap(maxPublishers:_:)`](/documentation/Combine/Publisher/flatMap(maxPublishers:_:)-4of8w)

Transforms all elements from an upstream publisher into a new publisher up to a maximum number of publishers you specify.

[`switchToLatest()`](/documentation/Combine/Publisher/switchToLatest()-453ht)

Republishes elements sent by the most recently received publisher.

[`switchToLatest()`](/documentation/Combine/Publisher/switchToLatest()-1c51y)

Republishes elements sent by the most recently received publisher.

[`switchToLatest()`](/documentation/Combine/Publisher/switchToLatest()-20v3t)

Republishes elements sent by the most recently received publisher.

[`switchToLatest()`](/documentation/Combine/Publisher/switchToLatest()-9eb3r)

Republishes elements sent by the most recently received publisher.

### Handling errors

[`assertNoFailure(_:file:line:)`](/documentation/Combine/Publisher/assertNoFailure(_:file:line:))

Raises a fatal error when its upstream publisher fails, and otherwise republishes all received input.

[`catch(_:)`](/documentation/Combine/Publisher/catch(_:))

Handles errors from an upstream publisher by replacing it with another publisher.

[`tryCatch(_:)`](/documentation/Combine/Publisher/tryCatch(_:))

Handles errors from an upstream publisher by either replacing it with another publisher or throwing a new error.

[`retry(_:)`](/documentation/Combine/Publisher/retry(_:))

Attempts to recreate a failed subscription with the upstream publisher up to the number of times you specify.

### Controlling timing

[`measureInterval(using:options:)`](/documentation/Combine/Publisher/measureInterval(using:options:))

Measures and emits the time interval between events received from an upstream publisher.

[`debounce(for:scheduler:options:)`](/documentation/Combine/Publisher/debounce(for:scheduler:options:))

Publishes elements only after a specified time interval elapses between events.

[`delay(for:tolerance:scheduler:options:)`](/documentation/Combine/Publisher/delay(for:tolerance:scheduler:options:))

Delays delivery of all output to the downstream receiver by a specified amount of time on a particular scheduler.

[`throttle(for:scheduler:latest:)`](/documentation/Combine/Publisher/throttle(for:scheduler:latest:))

Publishes either the most-recent or first element published by the upstream publisher in the specified time interval.

[`timeout(_:scheduler:options:customError:)`](/documentation/Combine/Publisher/timeout(_:scheduler:options:customError:))

Terminates publishing if the upstream publisher exceeds the specified time interval without producing an element.

### Encoding and decoding

[`encode(encoder:)`](/documentation/Combine/Publisher/encode(encoder:))

Encodes the output from upstream using a specified encoder.

[`decode(type:decoder:)`](/documentation/Combine/Publisher/decode(type:decoder:))

Decodes the output from the upstream using a specified decoder.

### Identifying properties with key paths

[`map(_:)`](/documentation/Combine/Publisher/map(_:)-6sm0a)

Publishes the value of a key path.

[`map(_:_:)`](/documentation/Combine/Publisher/map(_:_:))

Publishes the values of two key paths as a tuple.

[`map(_:_:_:)`](/documentation/Combine/Publisher/map(_:_:_:))

Publishes the values of three key paths as a tuple.

### Working with multiple subscribers

[`multicast(_:)`](/documentation/Combine/Publisher/multicast(_:))

Applies a closure to create a subject that delivers elements to subscribers.

[`multicast(subject:)`](/documentation/Combine/Publisher/multicast(subject:))

Provides a subject to deliver elements to multiple subscribers.

[`share()`](/documentation/Combine/Publisher/share())

Shares the output of an upstream publisher with multiple subscribers.

### Buffering elements

[`buffer(size:prefetch:whenFull:)`](/documentation/Combine/Publisher/buffer(size:prefetch:whenFull:))

Buffers elements received from an upstream publisher.

[`Publishers.PrefetchStrategy`](/documentation/Combine/Publishers/PrefetchStrategy)

A strategy for filling a buffer.

[`Publishers.BufferingStrategy`](/documentation/Combine/Publishers/BufferingStrategy)

A strategy that handles exhaustion of a buffer’s capacity.

### Performing type erasure

[`eraseToAnyPublisher()`](/documentation/Combine/Publisher/eraseToAnyPublisher())

Wraps this publisher with a type eraser.

### Specifying schedulers

[`subscribe(on:options:)`](/documentation/Combine/Publisher/subscribe(on:options:))

Specifies the scheduler on which to perform subscribe, cancel, and request operations.

[`receive(on:options:)`](/documentation/Combine/Publisher/receive(on:options:))

Specifies the scheduler on which to receive elements from the publisher.

### Adding explicit connectability

[`makeConnectable()`](/documentation/Combine/Publisher/makeConnectable())

Creates a connectable wrapper around the publisher.

### Connecting simple subscribers

[`assign(to:on:)`](/documentation/Combine/Publisher/assign(to:on:))

Assigns each element from a publisher to a property on an object.

[`assign(to:)`](/documentation/Combine/Publisher/assign(to:))

Republishes elements received from a publisher, by assigning them to a property marked as a publisher.

[`sink(receiveCompletion:receiveValue:)`](/documentation/Combine/Publisher/sink(receiveCompletion:receiveValue:))

Attaches a subscriber with closure-based behavior.

[`sink(receiveValue:)`](/documentation/Combine/Publisher/sink(receiveValue:))

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

### Accessing elements asynchronously

[`values`](/documentation/Combine/Publisher/values-1dm9r)

The elements produced by the publisher, as an asynchronous sequence.

[`values`](/documentation/Combine/Publisher/values-v7nz)

The elements produced by the publisher, as a throwing asynchronous sequence.

### Debugging

[`breakpoint(receiveSubscription:receiveOutput:receiveCompletion:)`](/documentation/Combine/Publisher/breakpoint(receiveSubscription:receiveOutput:receiveCompletion:))

Raises a debugger signal when a provided closure needs to stop the process in the debugger.

[`breakpointOnError()`](/documentation/Combine/Publisher/breakpointOnError())

Raises a debugger signal upon receiving a failure.

[`handleEvents(receiveSubscription:receiveOutput:receiveCompletion:receiveCancel:receiveRequest:)`](/documentation/Combine/Publisher/handleEvents(receiveSubscription:receiveOutput:receiveCompletion:receiveCancel:receiveRequest:))

Performs the specified closures when publisher events occur.

[`print(_:to:)`](/documentation/Combine/Publisher/print(_:to:))

Prints log messages for all publishing events.



---

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)