我正在尝试使用node.js中的Q模块来了解promises,但是我有一个小问题.
在这个例子中:
ModelA.create(/* params */)
.then(function(modelA){
return ModelB.create(/* params */);
})
.then(function(modelB){
return ModelC.create(/* params */);
})
.then(function(modelC){
// need to do stuff with modelA, modelB and modelC
})
.fail(/*do failure stuff*/);
Run Code Online (Sandbox Code Playgroud)
.create方法在每个.then()中返回一个promise,正如预期的那样,获取promise的已解析值.
但是在最后的.then()中,我需要拥有所有3个先前解析的promise值.
最好的方法是什么?