Skip to content

[Angular] Once an error in the effects chain occurs, no effects are triggered anymore #693

Answered by yackinn
edskeizer asked this question in Q&A
Discussion options

You must be logged in to vote

@edskeizer
You need to catch the error on your inner observable issued by the switchmap operator.
If you catch the the error on the obserable you complete the observable stream.

createTodo$ = this.actions$.pipe(
	ofType(createTodoRequestAction),
	switchMap((payload: { todoName: string }) =>
	  this.todosService.add$(payload.todoName).pipe(
	    map(todo => createTodoSuccessAction(todo)),	
        catchError(error => of(createTodoErrorAction(error)))
	  )
  	),
);

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by NetanelBasal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #692 on June 07, 2021 14:31.