Promise.all behavior with RxJS Observables?

后端 未结 4 1921
暖寄归人
暖寄归人 2020-11-27 17:12

In Angular 1.x I would sometimes need to make multiple http requests and do something with all the responses. I would throw all the promises in an array and cal

4条回答
  •  囚心锁ツ
    2020-11-27 17:13

    The more straightforward alternative for emulating Promise.all is to use the forkJoin operator (it starts all observables in parallel and join their last elements):

    • documentation
    • related link: Cf. RxJS: concat three promises, distinguish results

    A bit out of scope, but in case it helps, on the subject of chaining promises, you can use a simple flatMap : Cf. RxJS Promise Composition (passing data)

提交回复
热议问题