Observable using interval

Interval are timed observables. They tell to perform an event at regular basis. Intervals will help to perform a task regularly.

Below code is a way to create a Timed interval example.

The demo Interval will keep getting invoked at regular interval of a second. We have added a sleep that that we can see the events getting logged.

Since it is observed computation thread so sleep will help us in seeing the logs.

23-01-20 13:17:53 [main] [INFO ] [c.c.l.rxjava.observers.DemoObserver]- onSubscribe
23-01-20 13:17:54 [RxComputationThreadPool-2] [INFO ] [c.c.l.rxjava.observers.DemoObserver]- onNext -> 0
23-01-20 13:17:55 [RxComputationThreadPool-2] [INFO ] [c.c.l.rxjava.observers.DemoObserver]- onNext -> 1
23-01-20 13:17:56 [RxComputationThreadPool-2] [INFO ] [c.c.l.rxjava.observers.DemoObserver]- onNext -> 2