Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
Make Angular only redirect when both API calls have been completed?
  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]);
  }

Specifically, is there a way to make it so that the router.navigate only happens when all API calls (if required) have been completed?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use forkJoin from RxJs libary. you can see document here

in your case you can do:

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)
});

and then subscribe

observable.subscribe(({first, second}) => {
  // do some thing with first and second value.
  this.router.navigate([this.onComplete]);
})

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda