Skip to content

Instantly share code, notes, and snippets.

@DorukUlucay
Created November 23, 2017 17:06
Show Gist options
  • Select an option

  • Save DorukUlucay/0d369641191c03e98d9bcf71e38c8f59 to your computer and use it in GitHub Desktop.

Select an option

Save DorukUlucay/0d369641191c03e98d9bcf71e38c8f59 to your computer and use it in GitHub Desktop.
js promises
<script>
var aCallWithDelayOf_1secs = new Promise(function (resolve, reject) {
setTimeout(function () {
resolve('Success!');
}, 1000);
// reject('Failure!');
});
var aCallWithDelayOf_2secs = new Promise(function (resolve, reject) {
setTimeout(function () {
resolve('Success!');
}, 2000);
// reject('Failure!');
});
alert("now");
Promise.all([aCallWithDelayOf_1secs, aCallWithDelayOf_2secs]).then(function (results) {
alert("3 seconds");
});
//https://davidwalsh.name/promises
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment