I have an array of observables that I execute in parallel using:
let observables: Observable<any>[]
Observable.forkJoin(observables)
This works fine, however I need to sequentially execute an array of observables and only emit one result if the last observable has been completed. This is when I tried to use
Observable.concat(observables)
But this returns several results, and not just one - the combined result that I get when using forkJoin. So I really need a combination of the two.
I tried using the reduction function to execute them sequentially, for example:
return observables.reduce((previous, current) => {
return previous.flatMap(() => current);
}, Observable.empty());
But with this decision, observables are not fulfilled at all.
source
share