I am trying to combine observables, where each observables gets the input in a for loop. My problem is, that I would know how to do it without the for loop
, if I know the array the for loop
would loop over in advance -> I would just put everything inside the combineLatest
.
Does anyone know how I would do this, if I do not know the size of sections
?
Many thanks in advance!
getArticleSectionsContent(pageId: string): Observable<any> {
return this.getArticleSections(pageId).pipe(
switchMap(sections => {
return combineLatest([
this.getArticleSectionContent(pageId, sections[0].index),
this.getArticleSectionContent(pageId, sections[1].index),
this.getArticleSectionContent(pageId, sections[2].index),
]).pipe(
map(([a, b, c]) => {
return { a, b, c };
})
);
})
);
}