Rxjs - Subscription next(), error(), or complete() methods of http request not triggered when...

Discussão em 'Angular' iniciado por NickAth, Outubro 19, 2024.

  1. NickAth

    NickAth Guest

    In my angular + ngrx application, I have an @Effect triggered by an Action. Code is below

    @Effect()
    customAction$ = this._actions$.pipe(
    ofType<CustomAction>(Actions.CustomAction),
    tap(() => console.log('Custom Action was triggered')),
    switchMap((res) => {
    console.log('before http request...');
    this.myservice.DoApiCall().pipe(finalize(() => {
    console.log('finalize triggered...');
    })).subscribe(resultInner => {
    console.log('next() trigerred...');
    // other logic ....
    },
    () => {
    console.log('error() triggered...');
    });
    return EMPTY;
    })
    );


    My issue is when I have network troubles sometimes and the action is triggered (and then the http request tries to execute), the request fails to respond but neither error() method of the subscription is executed nor code in the finalize() operator. Is that even possible? I would guess that if a request fails to complete at least the finalize part should be executed always. Thanks in advance.

    Continue reading...

Compartilhe esta Página