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

149
Visualizações
RXJS MergeMap not getting executed

In the below code, the execution never goes to mergemap. Looking for some help with correcting this code.

Requirement is, once i get response from getBns method, i need to perform some operation with response and then using the tap operator to update few flags that are used in HTML.

Component.ts*

 this.bns$ = this.myService.getBns().pipe(
          mergeMap((bns) => {
            performloadKey()
            return bns
          }),
          tap((bns) => {
            console.log(bns);
          })
        );


this.bns$.pipe(takeUntil(this.destroyed$)).subscribe();

service.ts

getBns(): Observable<any>{
    return of(mockData); 
  }
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I suppose the performLoadKey is also returning an observable? If so, I guess you want to do the following:

this.bns$ = this.myService.getBns().pipe(
  mergeMap((bns) => performloadKey().pipe(
    mapTo(bns)
  )),
  tap((bns) => console.log(bns))
);
over 4 years ago · Santiago Trujillo Relatório

0

MergeMap only works if you return an Observable inside the callback. You are subscribing of(bns) so inside the callback you are returning the value bns. If bns isn't an Observable and doesn't emit any values, the pipe never continues.

over 4 years ago · Santiago Trujillo 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