Last active
November 15, 2016 12:28
-
-
Save dogmatic69/ff0724d5a8d1e0dd047687e13299dad9 to your computer and use it in GitHub Desktop.
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
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