11.1 · Publisher, Subscriber, Subscription and demand

Combine is a small protocol model with a large operator library on top. Once you know the four types and who talks to whom, every pipeline reads the same way.

Mental model. A publisher is a recipe, not a stream. Nothing happens until a subscriber attaches, and then the subscriber controls the pace by requesting demand.

The protocols

Who creates what, and when anything runs.

  1. What are Publisher, Subscriber, Subscription and Subscriber.Input/Failure, and when does a pipeline actually start? 11.1.1 · L2
    A Publisher declares an Output type and a Failure type (Never if it cannot fail) and one method, receive(subscriber:). A Subscriber has matching Input and…

Backpressure

Demand, and what happens when the consumer is slow.

  1. What is demand and backpressure in Combine, and how does a custom subscriber control it? 11.1.2 · L3
    Backpressure is the mechanism by which a slow consumer limits a fast producer. In Combine it is demand: a Subscribers.Demand is a count (.max(n)), .unlimited…

More in Combine