1
我遇到bluebirdconcurreny
問題。基本上我希望我的承諾能夠一個接一個地被解僱。我發現這可以使用bluebird
完成。這是我的代碼:javascript - 藍鳥未正確啓動承諾
var getdep = Promise.promisify(
function getdep(module, cb) {
console.log(module + " ...start ...")
ls(module, function(data) {
cb(null, data);
});
});
Promise.all([0,1,2,3,].map(function(data){
return getdep("[email protected]");
}, {concurrency: 1}))
.then(function(all){
console.log(all);
})
.catch(function(err){
console.log(err);
});
我所尊重的是類似於({concurrency: 1}
)。
[email protected] ...start ...
loading: [email protected]@latest
loading: [email protected]@latest
loading: [email protected]@latest
loading: [email protected]@latest
....
[email protected] ...start ...
loading: [email protected]@latest
loading: [email protected]@latest
loading: [email protected]@latest
loading: [email protected]@latest
... 等
,但我有什麼:
[email protected] ...start ...
[email protected] ...start ...
[email protected] ...start ...
[email protected] ...start ...
loading: [email protected]@latest
這意味着bluebird
是我的開始在同一時間所有的承諾。 你能告訴我我的代碼有什麼問題嗎?感謝
你有一個錯字)你把'concurrency'設置爲'Array.map'而不是'Promise.all'。最好還是在承諾鏈的每一步都要回報一些東西 – stasovlas