One Promise For Multiple Promises - Concurrency Issue
In the method 'myMethod' of my 'gulpfile.js' I want to create multiple Promises. The quantity depends on the array size (method parameter). When I call the method I want to make su
Solution 1:
At the time of the console.log, the first promise promise = del(array1, {force: true});
is not yet finished, so none of the code in the then
is yet executed. That's why your promises are empty.
You can simply return in a then another promise:
var myMethod = function(array1, array2){
var promise = del(array1, {force: true});
return promise.then(() => {
returnPromise.all(array2.map(array2value => {
returnnewPromise(function(resolve, reject) {
deleteEmpty(array2value, {force: true}, (err, deleted) => {
if (err) {
reject(err);
} else{
resolve()
}
});
});
}
});
}
Post a Comment for "One Promise For Multiple Promises - Concurrency Issue"