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

294
Visualizações
How to wait and execute other code until multiple subscribe observables are finished javascript

I have a piece of code which contains multiple http requests which are subscribed. Here an example of how one such subscribe function looks like:

this.http.post<any>(url, body).subscribe({
   next: data => {
       console.log(data);
   }
});

But depending on user input they are not always used (so sometimes there are some not accessible). After all the subscriptions are done that were neccesary, a function has to be called. Let's name that function subscribesDone().

How do I execute that function only after all the subscribes are done (while there are some subscribe funtions not being used, depending on the situation).

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

0

This isn't a very "proper" answer, but a way to do it until others give better answers:

make an array of booleans, one for every http call, all true. If a call is made, set its array slot to false and set it back to true when it returns. Every return, after setting the correct value to true, check if all bools are true. If all are true, do the final function

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