Complete callback in Observable.prototype.subscribe in Angular 2
I think what you are looking for is the .finally
function.
Invokes a specified action after the source observable sequence terminates gracefully or exceptionally. There is an alias called finallyAction for browsers < IE9
Here's an example: finally.md.
For rxjs 6
use pipe/finalize
:
import { finalize } from 'rxjs/operators';this.getData(params) .pipe( finalize(() => { // this is called on both success and error }) ) .subscribe( (successData) => { }, (err) => { } );