I need to construct a nested object from the result of three Observable streams and display the . All three observables return an array, and two depend on the result of the first. The code I have is as follows:
this.selectActiveFoos$.pipe(
concatMap(foos => {
return foos.map(foo => {
let bars$ = this.barQuery.selectBarsByFooId(foo.id);
let bazs$ = this.bazQuery.selectBazsByFooId(foo.id); // these observables return Observable<T[]>
return forkJoin([bars$, bazs$]).pipe(
map(([bars, bazs]) => {
return {
foo: foo,
bars: bars,
bazs: bazs
}
})
);
});
})).subscribe(result => {
console.log(result);
});
}
IntelliSense tells me that the type of result is as expected, i.e. a
{ foo: foo, bars: bar[], bazs: baz[] }
however, the console logs an observable as an output. This is really throwing me for a loop. I've searched online for quite some time but I can't seem to find an answer that works with nested arrays of Observable<T[]>.
I would appreciate any advice!
[forkJoin(), forkJoin(),..]for each element of thefoosarray. You need to show what is the structure of that array and how each observable to theforkJoinshould look like.