Skip to content

Instantly share code, notes, and snippets.

@e2goon
Created January 12, 2016 01:53
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 e2goon/548c4d947a4e08330cdb to your computer and use it in GitHub Desktop.
Save e2goon/548c4d947a4e08330cdb to your computer and use it in GitHub Desktop.
javascript promise pattern
function getItems() {
var promises = [];
promises.push(new Promise(function(resolve, reject) {
setTimeout(function() {
resolve();
}, Math.random() * 10000);
}));
return Promise.all(promises);
}
getItems
.then(function(items) {
// code
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment