Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!