I have a collection of Observables that retrieve different data types each. I'm chaining those Observable to get all the data I want for my page. Fact is all those informations are independent, so loading one should not block or interfere in loading the others. which I am not able to achieve.
Here is an example of what I've done for the moment:
getAll(): Observable<any[]> {
return this.getHome().pipe(
tap((home: Home) => this.application = home),
mergeMap((home: Home) =>
combineLatest([
this.getAssets(home.images).pipe(defaultIfEmpty([])),
this.getStyling(home.styling).pipe(defaultIfEmpty({})),
this.getCategories(home.categories).pipe(defaultIfEmpty([])),
])
)
);
}
Here, the Observable are successfully chained, so I get all the data I want, but combineLatest() does the next request once the previous is completed, and parent emits collected data once everything is finished which creates delay.
I've been trying to use merge() instead of combineLatest() so that each data received emits it instantly to the parent Observable, but apparently I just can't do that
So, how can I manage to chain those Observables so that each submit in child Observable does emit directly to parent Observable ?