So far, only one way to subscribe to an observable has been described: with callbacks. However, it is not the only way. We will now cover the different ways to subscribe to an observable, and will also cover how one can unsubscribe from an observable.
Subscription and disposal
Subscribing to an observable
When an observer subscribes to an observable, it listens to the observable with three handlers, as follows:
- on_next, which is called each time an item is emitted on the observable
- on_error, which is called when the observable completes on error
- on_completed, which is called when the observable completes on success
Handling each of these three kinds of events is optional. However, the on_error handler should always be implemented...