One Logo Pool Ball
Combine · IOS API REFERENCE

Subscriber

protocol · iOS 13.0+ · SDK 27.1

protocol Subscriber<Input, Failure> : CustomCombineIdentifierConvertible

A protocol that declares a type that can receive input from a publisher. A ``Subscriber`` instance receives a stream of elements from a ``Publisher``, along with life cycle events describing changes to their relationship. A given subscriber’s ``Subscriber/Input`` and ``Subscriber/Failure`` associated types must match the ``Publisher/Output`` and ``Publisher/Failure`` of its corresponding publisher. You connect a subscriber to a publisher by calling the publisher’s ``Publisher/subscribe(_:)-4u8kn`` method. After making this call, the publisher invokes the subscriber’s ``Subscriber/receive(subscription:)`` method. This gives the subscriber a ``Subscription`` instance, which it uses to demand elements from the publisher, and to optionally cancel the subscription. After the subscriber makes an initial demand, the publisher calls ``Subscriber/receive(_:)``, possibly asynchronously, to deliver newly-published elements. If the publisher stops publishing, it calls ``Subscriber/receive(completion:)``, using a parameter of type ``Subscribers/Completion`` to indicate whether publishing completes normally or with an error. Combine provides the following subscribers as operators on the ``Publisher`` type: - ``Publisher/sink(receiveCompletion:receiveValue:)`` executes arbitrary closures when it receives a completion signal and each time it receives a new element. - ``Publisher/assign(to:on:)`` writes each newly-received value to a property identified by a key path on a given instance.

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

Subscriber.receive()

The iOS SDK compiler rejected this binding: referencing instance method 'receive()' on 'Subscriber' requires the types 'Self.Input' and '()' be equivalent

All Combine types →