I have a series of observables that need to run sequentially, with each result depending on the previous one. However, I also need all the intermediate results in an array at the end, similar to what is achieved with the use of forkJoin
.
Below is the current code snippet:
getData$ = getResponses$
.pipe(
switchMap((data_1) => {
return getResponse_1$;
})
)
.pipe(
switchMap((data_2) => {
return getResponse_2$;
})
);
The issue is that getResponse_2$ relies on getResponse_1$, and getResponse_1$ relies on getResponses$. I am looking for a way to make the final result, getData$, an array of all intermediate results, similar to using forkJoin
. Is there a solution for this?