O'Reilly logo

Reactive Programming With Java 9 by Tejaswini Mandar Jog

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The observeOn() operator

The method observeOn() instructs the RxJava library to perform the given computation by the operator or by the Subscriber declared after the given definition, on the thread which has been provided by the Scheduler. The name observeOn suggests observing the items or events emitted by the Observable. If multiple operators are in chain then, after observing the data, one operator transmits it to the next operator. In the scenario that all the operators got completed and we have the Subscriber, then the items or events will eventually be passed on to the Subscriber.

Let's update the earlier code to use the observeOn() operator as shown in the following code:

 public class Demo_ObserveOn { public static void main(String[] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required