Chapter 7. Switching, Throttling, Windowing, and Buffering
It is not uncommon to run into situations where an Observable
is producing emissions faster than an Observer
can consume them. This happens particularly when you introduce concurrency, and the Observable
chain has different operators running on different Schedulers. Whether it is one operator struggling to keep up with a preceding one, or the final Observer
struggling to keep up with emissions from the upstream, bottlenecks can occur where emissions start to queue up behind slow operations.
Of course, the ideal way to handle bottlenecks is to leverage backpressure using Flowable instead of Observable
.The Flowable
is not much different than the Observable
other than that it tells the source to slow down by having the Observer
request emissions at its own pace, as we will learn about it in Chapter 8, Flowables and Backpressure. But not every source of emissions can be backpressured. You cannot instruct Observable.interval()
(or even...