【发布时间】:2019-02-12 17:17:05
【问题描述】:
我有类似的东西:
// Build requests array
const requests = [];
contacts.forEach(contact => {
requests.push(
this.httpService.post('/users', { name: contact.name })
);
});
// Run them all at once and do stuff when they all complete
return Observable.forkJoin(requests).pipe(
map(() => console.log('All requests are done!')),
catchError(() => console.log('Something went wrong'))
);
像这样使用forkJoin,所有的http请求都是一次性的。我怎样才能一一完成请求?也就是说,我希望请求 1 完成,然后运行请求 2 等。我找不到任何执行此操作的 rxjs 运算符。
【问题讨论】: