thanks for your reply.
Functions are already async, and I need to call func2 after func1 is done (they can't overlap)...
I wrote my this function using Bluebird, here is an example:
var Bluebird = Promise.noConflict();
var items = [
function () {
return new Bluebird(function (resolve, reject) {
console.log("promise1 pending");
setTimeout(function () {
console.log("promise1 fulfilled");
resolve();
}, 1000)
})
},
function () {
return new Bluebird(function (resolve, reject) {
console.log("promise2 pending");
setTimeout(function () {
console.log("promise2 fulfilled");
resolve();
}, 500)
})
},
];
Bluebird.each(items, function (item, i) {
return item();
});
This does exactly what I need, first calls "promise1 pending", then "promise1 fulfilled", then "promise2 pending" and "promise2 fulfilled"...
I tried to write this function with native Prosmises, but I couldn't figure out how.
Thank you for your help
func1,func2, andfunc3? Are they already async, or are they sync and needing a wrapper? Do you want to wait to callfunc2untilfunc1's work is complete, or can they overlap? What have you looked at so far, what's worked, what hasn't worked?