Subscribing and disposing

So, we have Observable (the thing that should be observed upon) and we have Observer (that should observe); now what? How to connect them? Observable and Observer are like an input device (be it keyboard or mouse) and the computer, we need something to connect them (even wireless input devices have some connectivity channels, be it Bluetooth or Wi-Fi).

The subscribe operator serves the purpose of the media by connecting an Observable to Observer. We can pass one to three methods (onNext, onComplete, onError) to the subscribe operator, or we can pass an instance of the Observer interface to the subscribe operator to get the Observable connected with an Observer.

So, let's take a look at the following example now: ...

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

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