Reputation: 20015
I don't want to do anything on next()
method, I want to handle error()
and complete()
.
This is my current solution that works well:
this.myService.myServiceObservable(params)
.subscribe(
() => {
/**/
},
error => {
// Handling errors here
},
() => {
// Handling `complete()` here
}
);
I feel that this: () => { /**/ }
is not the most elegant solution.
Anybody knows how to have the same result but not this ugly? Am I missing something?
Upvotes: 2
Views: 697
Reputation: 96979
You can use undefined
instead of a notification handler:
.subscribe(undefined,
err => { ... },
() => { ...}
);
Or you can pass so called "PartialObserver" object that has only handlers for the notifications you want:
.subscribe({
error: err => { ... },
complete: () => { ...}
});
Upvotes: 5