【发布时间】:2018-07-13 16:23:57
【问题描述】:
我可以使用 forkjoin 运算符成功进行多个并行 http 调用(例如调用所有销售数据),但是我需要根据每个第一个(sales)http 调用的结果连接进一步的 http 调用。我不确定 mergeMap 或 concat 运算符是否最好以及它们如何适合这里
示例数据是 销售
{saleId:100, name:'bob, uri:'http://testserver/sales/100'}
{saleId:101, name:'fred, uri:'http://testserver/sales/101'}
{saleId:102, name:'billy, uri:'http://testserver/sales/102'}
products
{id:1,saleId:101, detail:'test1', product:{id:200, uri:'http://testserver/product/200'} }
{id:1,saleId:101, detail:'test1', product:{id:201, uri:'http://testserver/product/201'} }
{id:1,saleId:101, detail:'test1', product:{id:202, uri:'http://testserver/product/202'} }
getServerChildNodes(childNodeObj: any[]): Observable<any> {
//observablesListArray contains http sales uri
return forkJoin(observablesListArray)
.map((data: any[]) => {
for (let i = 0; i < data.length; i++) {
outputData.push(data[i].json());
}
return outputData;
});
}
【问题讨论】:
标签: angular rxjs angular2-observables fork-join