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.

Throttle publisher data with backpressure

Throttle publisher data with backpressure - Swift Tutorial

From the course: Learning Combine with Swift

Start my 1-month free trial

Throttle publisher data with backpressure

- [Narrator] Backpressure is a quite overlooked, yet powerful control knob in Combine. We will spend a few minutes going through what backpressure is, and why you'd want to make use of it. In Combine, remember publishers only exist because of subscribers. As if often called a pull design, not a push design. Being a Subscriber-centric paradigm the subscriber tells the publisher it wants a subscription. It wants to ingest values emitted from the publisher. And also specify how many to ingest. Backpressure can be thought of as a tap, and you set the tap, or demand, of how much flow to be delivered through the tap continuously by turning the knob. Which then increases the demand incrementally, or vice versally decreases. As part of controlling down stream values, you have a few options at your disposal. Within your normal operators, you can set various buffering attributes such as with flatMap, which would constrain upstream…

Contents