【发布时间】:2020-05-15 21:06:16
【问题描述】:
我有两个可观察对象 A 和 B。 我必须先拿到 A,直到我能拿到 B。
如果它们是独立的,我可以做一些类似 forkJoin 的事情来获得结果。 但由于我只有在拿到 A 之后才能拿 B,所以我有点挣扎。 我尝试了 switchMap,但似乎也不起作用。
所以我想要达到的是:
- 得到可观察的A
- 获得可观察的 B
-
将 A 和 B 组合成结果 C
public loadConfiguration(): Observable<ProductConfiguration> { return this.service.getA().pipe( switchMap(response => { return this.service.getB(response.id); } ), map(result => this.getData(result)) // here i want A and B thogether so result should contain A and B ); }
目前我有点迷茫。 问候 奥利弗
【问题讨论】: