I have a very basic question concerning @ngrx effects: How to ignore an error that happens during the execution of an effect such that it doesn\'t affect future effect execu
The @Effect stream is completing when the error occurs, preventing any further actions.
The solution is to switch to a disposable stream. If an error occurs within the disposable stream it's okay, as the main @Effect stream always stays alive, and future actions continue to execute.
@Effect()
login$ = this.actions$
.ofType('LOGIN')
.switchMap(action => {
// This is the disposable stream!
// Errors can safely occur in here without killing the original stream
return Rx.Observable.of(action)
.map(action => {
// Code here that throws an error
})
.catch(error => {
// You could also return an 'Error' action here instead
return Observable.empty();
});
});
More info on this technique in this blog post: The Quest for Meatballs: Continue RxJS Streams When Errors Occur