Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

405
Views
Angular: flujo de ejecución de ruptura de función de canalización

Tengo el siguiente código:

 subscriber.pipe( switchMap(data => { this.getData().pipe( map(() => res), catchError(error => { return of(null); }) ); }), switchMap(data => { }) ).subscribe();

En caso de error en el primer switchMap, devuelvo (nulo), por lo que el siguiente switchMap recibe datos como nulos. Pero me gusta detener la ejecución en caso de que el primer switchMap vaya al bloque catchError, no debería ejecutar el segundo switchMap. ¿Hay una manera de lograr esto?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Ponga el catchError al final de la tubería.

 subscriber.pipe( switchMap(data => { ... }), switchMap(data => { ... }), catchError(error => { return of(null); }) ).subscribe(val => { // val will be null if any error happened })
over 4 years ago · Santiago Trujillo Report

0

Creo que puedes usar el filtro aquí. desde el error de captura puede devolver nulo y después del primer switchMap puede usar un filtro para filtrar nulo.

 subscriber.pipe( switchMap(data => { this.getData().pipe( map(() => res), catchError(error => { return null; }) ); }), filter(v => v), switchMap(data => { }) ).subscribe();
over 4 years ago · Santiago Trujillo Report

0

RxJS # VACÍO

EMPTY es un observable que no emite nada y se completa inmediatamente.

 subscriber.pipe( switchMap(data => { this.getData().pipe( map(() => res), catchError(_ => EMPTY) ); }), switchMap(data => { }) ).subscribe();
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!