From the course: Learning Combine with Swift

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Consume data with subscribers

Consume data with subscribers - Swift Tutorial

From the course: Learning Combine with Swift

Start my 1-month free trial

Consume data with subscribers

- [Narrator] As the counterparts to publishers, subscribers receive inputs from the publishers. In this video, we will explore subscribers in greater detail and understand how they interact within the combined ecosystem. The Subscriber Protocol sets a contract to receive sequences of values over time from publishers. Symmetrical to the publisher protocol, this protocol has two possible outcomes, input and failure. So subscribers will listen and ingest to data streams from publishers so long as they are emitting. This is known as an Unlimited Demand. This is done via the first of two ways subscribers handle data, sink is one of them. So Sink provides two types of closures, one for receiving a completion event and the other for receiving values. The other way subscribers handle values from publishers is through assign. Assign lets you assign the received values into a KVO compliant property of an object. Say the value…

Contents