RxJS: concat three promises, distinguish results

前端 未结 2 593
囚心锁ツ
囚心锁ツ 2020-12-19 04:47

I have three promises, Rest requests returning lists of data.
The third one has references (ids) to the first two lists, so I want to map these ids to corresponding name

2条回答
  •  青春惊慌失措
    2020-12-19 05:18

    If these are promises we are talking about, I think you can have a look at the forkJoin operator. Cf. https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/forkjoin.md, http://xgrommx.github.io/rx-book/content/observable/observable_methods/forkjoin.html

    You could then have something like :

    Rx.Observable.forkJoin(p1, p2, p3, function(p1,p2,p3){
    /* your combining code here */
    })
    

    In short, forkJoin has semantics similar to that of RSVP.all if you know the promises library RSVP.

提交回复
热议问题