The subscription method accepts three callbacks. The latter is for the full event.
doSome() {
this.service.myMethod()
.subscribe((num:any) => {
console.log(num);
}, (err) => {
this.handleError(err);
}, () => { // <----
this.handleComplete();
});
}
You can also use an operator for this finally.
doSome() {
this.service.myMethod()
.catch(this.handleError)
.finally(this.handleComplete) // <----
.subscribe((num:any) => {
console.log(num);
});
}
source
share