Angular Rxjs. don't close the subscription after reaching the error, but log the error in...

Discussão em 'Angular' iniciado por Evgeniy R, Novembro 25, 2024.

  1. Evgeniy R

    Evgeniy R Guest

    community. I have one problem. I need to log an error in Angular's error handler without closing the stream subscription when an error occurs.

    I have the following data stream:

    /**DATA Provider Service*/
    getData(settings): Observable<any> {
    return HttpClientGET$(settings).pipe(
    /***/
    map(response => transformMethod(response)),
    /***/
    tap(convertedData => sendData(convertedData))
    );
    }

    sendData(data: any): void {
    this.replaySubject.next(data);
    }

    getConvertedData(): Observable<any> {
    this.replaySubject.asObservable();
    }


    /**Parent Component*/

    ngOnInit(): void {
    this.changePositionStream$.pipe(
    switchMap((settings) => this.dataService.getData(settings))
    ).subscribe();
    }


    /**Child - Data Component*/

    ngONInit(): void {
    this.service.getConvertedData().subscribe();
    }


    Issue - an error can be caught in the Angular error handler when the error stream doesn't interrupt or use the throwError(). But when an error is thrown the subscription is closing.

    How do I log an error without closing the data subscription?

    Continue reading...

Compartilhe esta Página