Using Observable.create()
Let's start by creating a source Observable using Observable.create(). A source Observable is an Observable from where emissions originate. It is the starting point of our Observable chain (pipeline of operators). The Observable.create() factory allows us to create an Observable by providing a lambda that accepts an Observable emitter.
Actually, the create() method accepts as a parameter an object of the ObservableOnSubscribe type that has only one method, subscribe(ObservableEmitter emitter), which accepts an ObservableEmitter type, which, in turn, extends the Emitter interface that has three methods: onNext(), onError(), and onComplete(). Since ObservableOnSubscribe is a functional interface – it has one abstract ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access