【发布时间】:2019-10-25 10:22:38
【问题描述】:
我正在尝试组合可观察对象,其中每个可观察对象在 for 循环中获取输入。我的问题是,如果我知道for loop 会提前循环的数组,我会知道如何做到没有for loop -> 我会将所有内容都放在@987654323 中@。
如果我不知道sections 的大小,有人知道我会怎么做吗?
非常感谢!
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 };
})
);
})
);
}
【问题讨论】:
-
有人有想法吗?
标签: loops angular2-observables combinelatest