Instance Method

sink(receiveCompletion:receiveValue:)

Attaches a subscriber with closure-based behavior.

Declaration

func sink(receiveCompletion: @escaping ((Subscribers.Completion<Self.Failure>) -> Void), receiveValue: @escaping ((Self.Output) -> Void)) -> AnyCancellable

Parameters

receiveCompletion

The closure to execute on receipt of a value. If nil, the sink uses an empty closure.

receiveValue

The closure to execute on completion. If nil, the sink uses an empty closure.

Return Value

A subscriber that performs the provided closures upon receiving values or completion.

Discussion

This method creates the subscriber and immediately requests an unlimited number of values, prior to returning the subscriber.

See Also

Connecting Simple Subscribers

func assign<Root>(to: ReferenceWritableKeyPath<Root, Self.Output>, on: Root) -> AnyCancellable

Assigns a publisher’s output to a property of an object.

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

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