I use subscribe method on observable (result of http.get) in Angular 2 final version. While the first argument of the subscribe method is function which gets data from backend, the second one is function which is executed on error (like status http code 404), I don't understand meaning of the third argunent/function.
In hope it is executed always when the request has ended (with either success or error), I remove/stop loading indicator in it, but the third function is not called on error.
The third argument of every sequence is the complete handler. It is invoked with no params and just notifies the sequence finished.
Observable.from([1,3]).subscribe(
(v => console.log('value: ', v)),
(e => console.log('error: ', e)),
(() => console.log('the sequence completed!'))
would print:
value: 1
value: 2
the sequence completed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With