【发布时间】:2018-03-15 16:51:02
【问题描述】:
我的情况是我需要进行 5 个可以并行执行的 http 调用 + 需要在这 5 个之后执行的另一个 http 调用。
我在前 5 个中使用了 forkJoin,但我不知道如何链接 flatMap(或其他函数)。
forkJoin(
firstObservable,
secondObservable,
thirdObservable,
..)
.subscribe(results => {
this.myComposedObject = results[0];
let secondResult = results[1];
let thirdResult = results[2];
[...]
// !!! AT THIS POINT I WOULD NEED TO MAKE AN EXTRA CALL!
// results[1] contains data I need to make the extra call
//
this.myComposedObject.second = secondResult;
this.myComposedObject.third = thirdResult;
});
我在组件中执行此操作,所以最后我将数据分配给 myComposedObject。
【问题讨论】:
标签: angular http rxjs chaining