Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

209
Vistas
¿Hacer que Angular solo redirija cuando se hayan completado ambas llamadas a la API?
 completeMedicalDataSubmission(forReview: boolean, success: MedicalData, newStatus: Status | undefined ) { let msg = this.translate.instant("GENERAL.DATA_SAVED"); this.snackBar.open(msg, '\u2716', {duration: 8000, panelClass: ['goodPanel']}); if (forReview) { this.patientDataReviewService.requestPatientDataReviewByPatient(success.medicalDataId!).subscribe(success => { if (this.onComplete !== null) { this.router.navigate([this.onComplete]); } }) } if (newStatus) { this.patientDataReviewService.updatePatientDataReviewByResearcher(this.id!, this.demographicMedicalData!.medicalDataId!, this.demographicMedicalData!.version!, newStatus).subscribe() } if (!forReview && this.onComplete !== null) this.router.navigate([this.onComplete]); }

Específicamente, ¿hay alguna manera de hacer que el router.navigate solo suceda cuando se hayan completado todas las llamadas a la API (si es necesario)?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Puede usar forkJoin de la biblioteca RxJs. Puedes ver el documento aquí

en tu caso puedes hacer:

 import { forkJoin } from 'rxjs'; const observable = forkJoin({ first: this.patientDataReviewService.requestPatientDataReviewByPatient(success.medicalDataId!), second: this.patientDataReviewService.updatePatientDataReviewByResearcher(this.id!, this.demographicMedicalData!.medicalDataId!, this.demographicMedicalData!.version!, newStatus) });

y luego suscríbete

 observable.subscribe(({first, second}) => { // do some thing with first and second value. this.router.navigate([this.onComplete]); })
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda