To listen to data on an observable, we must call the subscribe() method. This method returns a subscription, which we can use later to stop reacting to the incoming data if we are no longer interested in it.
The subscribe() method of observables has the following signature:
observable.subscribe(onNext,onError,onCompleted);
All parameters are optional and can be omitted if we are not interested in this type of event:
- onNext: This is a function to be called every time new data is propagated through the observable
- onError: This is a function to be called every time an error occurs in the observable
- onCompleted: This is a function to be called when the observable is completed
The easiest way to subscribe ...