In the RxJava world, we have four main players:
Observable
Observer
Subscriber
Subjects
Observables and Subjects are the two "producing" entities. Observers and Subscribers are the two "consuming" entities.
When we have to execute something asynchronously with a lite level of complexity, Java provides classic classes, such as Thread
, Future
, FutureTask
, CompletableFuture
, to approach the problem. When the level of complexity goes up, these solutions tend to become messy and hard to maintain. Most of all, they cannot be chained.
RxJava Observables were designed to solve these issues. They are flexible and easy to use, they can be chained, and they can work on a single result routine or, even better, on sequences. Whenever you want to emit a single scalar value or a sequence of values, or even an infinite value stream, you can use an Observable.
The Observable life cycle contains three possible events that we can easily compare to Iterable life cycle events...