Created
November 23, 2017 17:06
-
-
Save DorukUlucay/0d369641191c03e98d9bcf71e38c8f59 to your computer and use it in GitHub Desktop.
js promises
This file contains hidden or 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
| <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