Last active
September 18, 2015 07:46
-
-
Save dnasca/42c19502fe3b02bd3f3e to your computer and use it in GitHub Desktop.
the most basic example of an async cb in es5 (the old way)
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
| //the most basic async cb in es5 | |
| var sleep = function(ms) { | |
| var promise = new Promise(function(resolve, reject) { | |
| setTimeout(function() { | |
| resolve("the result"); | |
| }, ms); | |
| }); | |
| return promise; | |
| }; | |
| var promise = sleep(2000, function(result) { | |
| console.log(result); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment