Skip to content

Instantly share code, notes, and snippets.

@dnasca
Last active September 18, 2015 07:46
Show Gist options
  • Select an option

  • Save dnasca/42c19502fe3b02bd3f3e to your computer and use it in GitHub Desktop.

Select an option

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)
//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