Throughout this book, I emphasized the "push-based" nature of Observables. Pushing items synchronously and one at a time from the source all the way to the Observer
is indeed how Observable
chains work by default without any concurrency.
For instance, the following is an Observable
that will emit the numbers 1 through 999,999,999. It will map each integer to a MyItem
instance, which simply holds it as a property. But let's slow down the processing of each emission by 50 milliseconds in the Observer
. This shows that even if the downstream is slowly processing each emission, the upstream synchronously keeps pace with it. This is because one thread is doing all the work:
Unlock full access