Interface Subscriber

Instead of an Observer, Flowable uses a Subscriber to consume emissions and events at the end of a Flowable chain. If you pass only lambda event arguments (and not an entire Subscriber object), subscribe() does not return a Disposable, but rather an org.reactivestreams.Subscription, which can be disposed of by calling cancel() instead of dispose(). Subscription can also serve another purpose; it communicates upstream how many items are wanted using its request() method. Subscription can also be leveraged in the onSubscribe() method of Subscriber, which can call the request() method (and pass in the number of the requested elements) the moment it is ready to receive emissions.

Just like an Observer, the quickest way to ...

Get Learning RxJava - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.