As we discussed earlier, in reactive programming, Observable
has an underlying computation that produces values that can be consumed by a consumer (Observer
). The most important thing here is that the consumer (Observer
) doesn't pull values here; rather, Observable
pushes the values to the consumer. So, we can say that an Observable
interface is a push-based, composable Iterator that emits its items through a series of operators to the final Observer
, which finally consumes the items. Let's now break these things down sequentially to understand it better:
Observer
subscribes toObservable
Observable
starts emitting the items that it has in itObserver
reacts to whatever item theObservable
emits
So, let's delve into how Observable
works through its events/methods, namely onNext
, onComplete
, and onError
.