79105601

Date: 2024-10-19 18:04:46
Score: 2.5
Natty:
Report link

You are probably facing the same issue I faced several years ago. This is a question and the answer: https://stackoverflow.com/a/45882434/2909375

Angular's http client sometimes doesn't call any rxjs callbacks in case of some network troubles or very fast requests.

Also, I would suggest to you to not subscribe inside effects. Instead, you have to return underlying observable:

@Effect()
customAction$ = this._actions$.pipe(
    ofType<CustomAction>(Actions.CustomAction),
    tap(() => console.log('Custom Action was triggered')),
    switchMap(() => this.myservice.DoApiCall().pipe(
        catchError(() => {
            console.log('error() triggered...');
            return EMPTY;
        }),
        finalize(() => {
            console.log('finalize triggered...');
        }),
    )),
);

I put nested pipe which is not necessary but will help you avoid logging at this._actions$ observable completion/error.

If you want your requests won't be canceled once you emit next action, you should replace switchMap to mergeMap.

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): facing the same issue
Posted by: egorgrushin