Skip to content

Instantly share code, notes, and snippets.

@lcfd
Created February 8, 2017 15:51
Show Gist options
  • Save lcfd/8a5bdd0c8301a5ac3638e3a0ca786de3 to your computer and use it in GitHub Desktop.
Save lcfd/8a5bdd0c8301a5ac3638e3a0ca786de3 to your computer and use it in GitHub Desktop.
Es6 and Promise example
var pr1 = new Promise((resolve, reject) => {
setTimeout(function () {
resolve([1,3,4,46,234,33,4,536]);
}, 500);
})
var pr2 = new Promise((resolve, reject) => {
setTimeout(function () {
resolve(20);
}, 1000);
})
let printValues = (values) => {
console.log('Values: ', values);
}
Promise
.all([pr1, pr2])
.then(printValues)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment