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[] ...

Get Reactive Programming With Java 9 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.