【发布时间】:2014-10-11 14:14:12
【问题描述】:
在RSVP.js中有一个很优雅的成语:
var promises = [2, 3, 5, 7, 11, 13].map(function(id){
return getJSON("/post/" + id + ".json");
});
RSVP.all(promises).then(function(posts) {
// posts contains an array of results for the given promises
}).catch(function(reason){
// if any of the promises fails.
});
但是,我使用的库已经依赖并公开了一些 bluebird's api。所以我宁愿避免混入 RSVP.js,即使它有时看起来更优雅。
bluebird 中的 RSVP.js 代码 sn-p 的等价物是什么?
【问题讨论】:
-
还是一样的
Promise.all(promises).then(...)。
标签: javascript promise bluebird rsvp.js