Subscriber – the Observer interface
In RxKotlin 1.x, the Subscriber operator essentially became an Observer type in RxKotlin 2.x. There is an Observer type in RxKotlin 1.x, but the Subscriber value is what you pass to the subscribe() method, and it implements Observer. In RxJava 2.x, a Subscriber operator only exists when talking about Flowables.Â
As you can see in the previous examples in this chapter, an Observer type is an interface with four methods in it, namely 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 the Observer type and calls them. Here is a short description of the following four methods:
onNext: TheObservablecalls this method ofObserverto pass each of the items one by oneonComplete: When theObservablewants to denote that it's done with passing items to theÂonNextmethod, it calls theonCompletemethod ofObserveronError: WhenObservable...