Using Observable.create()

Let's start with creating a source Observable using Observable.create(). Relatively speaking, a source Observable is an Observable where emissions originate from and is the starting point of our Observable chain.

The Observable.create() factory allows us to create an Observable by providing a lambda receiving an Observable emitter. We can call the Observable emitter's onNext() method to pass emissions  (one a time) up the chain as well as onComplete() to signal completion and communicate that there will be no more items. These onNext() calls will pass these items up the chain towards the Observer, where it will print each item, as shown in the following code snippet:

    import io.reactivex.Observable; public class ...

Get Learning RxJava now with O’Reilly online learning.

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