rxjs subscription add() finally code example
Example: finally suscribe typescript
So the subscribe function takes three parameters:
onNext
onError
onCompleted
this._heroService.addHero(this.hero).subscribe(
hero=> this.hero= hero,
error => console.log("Error: ", error),
function(){ this._router.navigate(['HeroDetail', { id: this.hero.id }]) }
);
or
this._heroService.addHero(this.hero).subscribe({
next: event => { console.log(event) },
error: error => { console.log(error) },
complete: () => { console.log('complete') }
});