I am looking to optimize the process of making API calls by running two in parallel and then a third immediately after both have completed. I have successfully implemented parallel API calls using mergeMap and consecutive calls using concatMap, but now I want to combine the two methods.
//Call API1 and API2 in Parallel
// from([apiCall(1), apiCall(2)]).pipe(
// mergeMap(e=>e)
// ).subscribe(x => console.log(x));
//Call API1 and API2 consecutively
// from([apiCall(1), apiCall(2)]).pipe(
// concatMap(e=>e)
// ).subscribe(x => console.log(x));
//Call API1 and API2 in Parallel and API 3 right after both finishes
from([apiCall(1), apiCall(2), apiCall(3)]).pipe(
// ????
).subscribe(x => console.log(x));
Any suggestions on how to achieve this?
Check out the Stackblitz playground for experimentation: https://stackblitz.com/edit/playground-rxjs-263xwk