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

175
Views
forkJoin but next observable depends on the one before

https://www.learnrxjs.io/learn-rxjs/operators/combination/forkjoin

const example = forkJoin({
  // emit 'Hello' immediately
  sourceOne: of('Hello'),
  // emit 'World' after 1 second
  sourceTwo: of('World').pipe(delay(1000)),
  // throw error
  sourceThree: throwError('This will error')
}).pipe(catchError(error => of(error)));

// output: 'This will Error'
const subscribe = example.subscribe(val => console.log(val));

That's the main implementation but in my case, to call sourceTwo I need to use the data from sourceOne and the same with sourceThree. All calls need the previous observable in order to fetch data.

I only care about final result, don't need to merge anything, just do what this example does, show what sourceThree returns

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

forkJoin is intended to run calls in parallel, like Promise.all(). In your case, you cannot do that since the calls depend on each other.

Instead, you can pipe them. If you can parallelize 2 and 3, you can do something like the following.

sourceOne.pipe(
  res => forkJoin(makeCall2(res), makeCall3(res))
)

To complete the Promise comparison:

makeCall().then(res => Promise.all([
    makeCall2(res),
    makeCall3(res)
]));
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!