Subscribers - the Observer interface

The Subscriber from RxKotlin 1.x,  essentially became an Observer in RxKotlin 2.x. There is an Observer interface in RxKotlin 1.x, but Subscriber is what you pass to the subscribe() method, and it implements Observer. However, In RxJava 2.x, Subscriber only exists when talking about Flowables, which we will cover in Chapter 4Introduction to Backpressure and Flowables.

As you can see in the previous examples in this chapter, Observer is an interface with four methods in it—onNext(item:T), onError(error:Throwable), onComplete(), and onSubscribe(d:Disposable). As stated earlier, when we connect Observable to Observer, it looks for these four methods in Observer and calls them. So, the following is a short ...

Get Reactive Programming in Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.