Utility Operators: DoOnEach, and Cache

Learn about the utility operators of RxJava.

Utility operators

RxJava has a handful of utility operators that don’t necessarily modify the emissions themselves through transformations or filters, but instead allow us to do various actions such as getting insight into events in the stream itself—for debugging or logging purposes—or caching results emitted in the stream.


The .doOnEach() function is an Operator that enables listening to events that occur in an Observable stream, or in other words when .onNext(), .onError() and .onComplete() are invoked by providing an Observer. Generally, this operator is used if we would like to perform a side-effect when an event occurs. There are also several .doX() operators, such as .doOnNext(), .doOnError(), and .doOnComplete(), available if we’re interested in listening only to a specific event.

Get hands-on with 1200+ tech skills courses.