Created
February 10, 2014 18:02
-
-
Save kepek/8921004 to your computer and use it in GitHub Desktop.
JavaScript Synchronous (Deferred) Functions.
This file contains 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
function sayIt(ms, def) { | |
setTimeout(function() { | |
console.log('middle'); | |
def.resolve(); | |
return 10; | |
}, ms); | |
} | |
function slowPromise() { | |
var def = $.Deferred(); | |
var result = sayIt(2000, def); | |
return def; | |
} | |
slowPromise().then(function() { | |
console.log('end'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment