Last active
January 26, 2016 10:47
-
-
Save AmrAbdulrahman/59971ceaa24750be244d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function asyncOperation() { | |
// returns promise | |
} | |
var promises = []; | |
for (var i=0; i<=10; i++) { | |
var promise = asyncOperation(); | |
promises.push(promise); | |
} | |
// now we need to execute some logic after all promises get resolved | |
// we can use .all() as following | |
q | |
.all(promises) | |
.then(function() { | |
console.log('all promises resolved!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment