I am using RxJS in an Angular 14 app.
First I have 2 api calls to make, they can be done in parallel. So I have used forkjoin.
Then, I need to use the results from these calls. In 2 other api calls. But these 2 calls need to be made one after the other has completed.
Both the calls need to use the response form the forkjoin.
Below the code snippet does not work as 'apiCallD' does not have access to 'resA', but it is to try an show you what I am explaining.
getBooks(bookInfoToSend, otherInfoToSend) {
forkJoin([
this.apiCallA(bookInfoToSend),
this.apiCallB(otherInfoToSend)
]).pipe(
concatMap(([resA, resB]) => this.apiCallC(resA, resB)),
concatMap( ()=> this.apiCallD(resA))
).subscribe()
}