Open jmeinlschmidt opened 1 year ago
Start a new pull request in StackBlitz Codeflow.
I have the same issue, when try to make HTTP request
loadUsers$ = createEffect((actions) =>
actions.pipe(
ofType(loadUsers),
switchMap(() => this.usersService.getAll()),
catchError((err) => { notifyAboutError(err); return NEVER; }),
tap(setUserList)
)
);
After an error occurs, the effect stops. One possible solution is to refrain from catching errors within the action pipe and instead catch them in the HTTP response stream, as illustrated below:
loadUsers$ = createEffect((actions) =>
actions.pipe(
ofType(loadUsers),
switchMap(() => this.usersService.getAll().pipe(catchError(() => {
notifyAboutError(err);
return of(null);
}))),
tap((result) => {
if (!result) return;
setUserList(result);
})
)
);
Which @ngneat/effects-* package(s) are the source of the bug?
effects-ng
Is this a regression?
No
Description
Operator
catchError
in effects is not working and after throwing an error, the effect stops emitting. Please see full example in stackblitz.This is related to https://github.com/ngneat/effects/discussions/34. I think this applies to effect functions as well, see
createEffectFn
implementation.Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-tvg994?file=src%2Fmain.ts
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in
No response
Anything else?
No response
Do you want to create a pull request?
No