Observable with rx broken after error
When an error is caught, the observable returned by catch
is used to continue the chain. And the returned observable completes, which completes the effect and sees ngrx
unsubscribe from the effect.
Move the map
and catch
into the switchMap
:
@Effect() login = this.actions
.ofType(LoginActions.ATTEMPT_LOGIN)
.map(toPayload)
.switchMap(payload => this.loginService.attemptLogin(payload)
.map(response => new LoginActions.LoginSuccess(response))
.catch(error => of(new LoginActions.LoginFailed(error)))
);
Catching inside the switchMap
won't complete the effect.