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

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

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 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!