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

113
Visualizações
Can I subscribe inside the combineLatest by the return result?

I want to use combineLatest to get a bunch of result. Then one of result is passed as input parameter to do another subscribe call.

combineLatest([first, second, third, four, five]).pipe(take(1)).
   subscribe(([a, b, c, d, e]) => {
        this.showData1(a);
        this.showData2(b);
        this.showData3(c);
        this.showData4(d);
        if(e > 8) {
           this.myService.updateStatus(e).subscribe(
              result => this.setupStatus(result)
           );
       }
   });

The logic is from the 5 results, 4 of them are used for rendering screen. The last one I use it to do a subscribe, its returning result will used some where.

But I feel that it is not right because sometimes it seems this.setupStatus(result) is not running inside the combineLatest. Memory leak?

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

0

hard to diagnose why it wouldn't be running without knowing more about the observables. but I'd do it something like this to avoid nested subscribes and make this a little easier to diagnose / manage:

combineLatest([first, second, third, four, five]).pipe(
   take(1),
   switchMap(([a, b, c, d, e]) => {
        this.showData1(a);
        this.showData2(b);
        this.showData3(c);
        this.showData4(d);
        return this.myService.updateStatus(e);
   })
).subscribe(result => this.setupStatus(result));

possibly structuring a little differently depending on when exactly I want things to happen.

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