When an error occurs, the observable stops sending new data. We can use different strategies, such as switching to another observable or retry, but these are more advanced so first we will see how an observer can be notified by an error. As you probably remember, the
subscribe() method from the
observable object lets you pass up to three functions or allows an observer to be notified when an error occurs.
Take a look at the following signature:
observable.subscribe([onNext], [onError], [onCompleted]);
The parameters are optional:
onNext: This function is to be called when new data is available in this
observable. The function receives the data itself as a parameter.
onError: This function is to be called when an error is propagated through this
observable. This function received the
Erroras a parameter.
onCompleted: This function is to be called when the
observableis exhausted and all the data has already been propagated.
This method also has an overloaded implementation...