Shield observable chain

35 Views Asked by At

I have this RxJS observable chain. I want to remove final error handling (since there is some error handling in chain which I need there) from chain and leave it to Global error handler. Whatever I tried to do, when error is returned from http call, subscription is canceled. So I want to leave error handling to global error handler and to keep subscription active.

// onUpdateScale$ is Observable 

this.onUpdateScale$.pipe(
    switchMap(() => this.svc.update(this.getUpdateRequest()).pipe( // http call
        catchError(err => {
            this.mbs.dispatchEvent(this.events.udateScaleFailed);
            console.log(err);     /// I want to remove this since proper error handling is in global error handler.
            return of(undefined); /// also, here I want this:  return throwError(() => error)
        }),                                         ///
        filter(data => {                            /// And remove this since it would be unnecessary
            return data != undefined;               /// 
        })                                          ///
    ))
).subscribe({
    next: (data) => {
        .. do something
    }
});
0

There are 0 best solutions below