Skip to content

Instantly share code, notes, and snippets.

@AmrAbdulrahman
Last active January 26, 2016 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmrAbdulrahman/59971ceaa24750be244d to your computer and use it in GitHub Desktop.
Save AmrAbdulrahman/59971ceaa24750be244d to your computer and use it in GitHub Desktop.
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