作者:波波微博1987_704 | 来源:互联网 | 2023-09-13 22:21
Ihaveafunctionthatneedstheresultofthreepriorpromisespassedtoit.Oneislinearlydepend
I have a function that needs the result of three prior promises passed to it. One is linearly dependent and the other two can run concurrently. I want to use q.all to resolve the three promises, and then pass the results onto the fourth using .spread. My code however does not work. Any help would be appreciated.
我有一个函数需要传递给它的三个先前的承诺的结果。一个是线性相关的,另外两个可以同时运行。我想使用q.all解析三个promise,然后使用.spread将结果传递给第四个。但我的代码不起作用。任何帮助,将不胜感激。
var p1 = doWork(data);
var p2 = p1.then(doMoreWork);
var p3 = doConcurrentWork(data);
return q.all([p1,p2,p3]).spread(funcWith3params)
.fail(function(err) {
console.log(err):
}
I can trace the code in node-inspector and see that the first 3 promises are being called. However, the function that .spread calls is not being called. Any clues as to why? Also .fail isn't being hit either.
我可以在node-inspector中跟踪代码,看看是否正在调用前3个promise。但是,.spread调用的函数没有被调用。任何线索为什么?另外.fail也没被击中。
2 个解决方案