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
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)
]));