Skip to content

Instantly share code, notes, and snippets.

@dogmatic69
Last active November 15, 2016 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogmatic69/ff0724d5a8d1e0dd047687e13299dad9 to your computer and use it in GitHub Desktop.
Save dogmatic69/ff0724d5a8d1e0dd047687e13299dad9 to your computer and use it in GitHub Desktop.
console.log($q);
function asyncGreet(name) {
return $q(function(resolve, reject) {
console.log("timeout starts");
setTimeout(function() {
console.log("resolving");
console.log("resolve: ", resolve);
console.log(resolve('Hello, ' + name + '!'));
}, 2000);
});
}
var prom = asyncGreet('Robin Hood');
return prom
.then(function(greeting) {
console.log('Success: ' + greeting);
}, function(reason) {
console.log('Failed: ' + reason);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment