From the course: Learning Combine with Swift

Unlock the full course today

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

Understand the Combine life cycle

Understand the Combine life cycle - Swift Tutorial

From the course: Learning Combine with Swift

Start my 1-month free trial

Understand the Combine life cycle

- [Instructor] It helps to take a birds-eye view of the Combine lifecycle so that you can understand how each of the actors interacts, the sequence of events, what comes before what. Let's get those answers for you and set the foundation for the remainder of the course. So we have a subscriber and a publisher. Say the publisher asynchronously calls a URL and returns data. The subscriber first subscribes to that publisher, which in turn creates a subscription that is given back to the subscriber. With the subscription in place, the subscriber can then request values from the publisher, tapping into a stream of events being returned from the publisher. Now, all subscribers conform to the cancelable protocol, allow them to cancel the subscription if there are no subscribers left. The publisher terminates as well. Sub-publishers, if defined so, could also emit a completion or failure signal causing the subscription…

Contents