-
I'm submitting a...
Current behaviorIf an error occurs in the chain of an effect, all effects dispatched afterwards are ignored. Expected behaviorI would expect subsequent effects to be handled normally. Minimal reproduction of the problem with instructionsSee this Stackblitz with the issue. I made an example api call in TodoService that throws an error when adding a second todo. A third todo should be created, but is ignored. What is the motivation / use case for changing the behavior?When a todo api call fails (for some reason), the next addition should just work. This is not the case now: all actions dispatched afterwards are ignored. Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I'll look into it. |
Beta Was this translation helpful? Give feedback.
-
@edskeizer 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)))
)
),
); |
Beta Was this translation helpful? Give feedback.
@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.