Если ваша цель состоит в том, чтобы свести наблюдаемую из наблюдаемых к одной наблюдаемой, которая генерирует массив результатов каждой внутренней наблюдаемой, тогда объединить все может быть тем, что вы ищете.
StackBlitz демо:
import { fromEvent, interval, from, Observable } from "rxjs";
import { map, combineAll, take } from "rxjs/operators";
/*
Create an Observable that emits every second, up until count times.
*/
function createIntervalObs(count: number): Observable<any> {
return interval(1000).pipe(
map(out => `Obs${count}@${out}`),
take(count)
)
}
const outerObs$ = from([5, 4, 3, 2, 1]).pipe(
map(num => createIntervalObs(num))
)
outerObs$.pipe(
combineAll()
).subscribe(out => {
console.log(out);
})
Вывод:
["Obs5@0", "Obs4@0", "Obs3@0", "Obs2@0", "Obs1@0"]
["Obs5@1", "Obs4@0", "Obs3@0", "Obs2@0", "Obs1@0"]
["Obs5@1", "Obs4@1", "Obs3@0", "Obs2@0", "Obs1@0"]
["Obs5@1", "Obs4@1", "Obs3@1", "Obs2@0", "Obs1@0"]
["Obs5@1", "Obs4@1", "Obs3@1", "Obs2@1", "Obs1@0"]
["Obs5@2", "Obs4@1", "Obs3@1", "Obs2@1", "Obs1@0"]
["Obs5@2", "Obs4@2", "Obs3@1", "Obs2@1", "Obs1@0"]
["Obs5@2", "Obs4@2", "Obs3@2", "Obs2@1", "Obs1@0"]
["Obs5@3", "Obs4@2", "Obs3@2", "Obs2@1", "Obs1@0"]
["Obs5@3", "Obs4@3", "Obs3@2", "Obs2@1", "Obs1@0"]
["Obs5@4", "Obs4@3", "Obs3@2", "Obs2@1", "Obs1@0"]