Instance Method

sink(receiveValue:)

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

Declaration

func sink(receiveValue: @escaping ((Output) -> Void)) -> AnyCancellable
Available when Failure is Never.

Parameters

receiveValue

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

Return Value

A subscriber that performs the provided closure upon receiving values.

Discussion

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