Last active
December 11, 2015 12:38
-
-
Save ninjascribble/4602255 to your computer and use it in GitHub Desktop.
jQuery $.Deferred chaining example. jsfiddle: http://jsfiddle.net/B5eZ9/1/
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
var a = getPromise(50) | |
, b = getPromise.bind(document, 1200) | |
, c = getPromise.bind(document, 400); | |
a.then(b).then(c).done(finish); | |
function getPromise(ttl) { | |
var deferred = $.Deferred(); | |
console.log(ttl + 'ms until resolve()'); | |
setTimeout(deferred.resolve, ttl); | |
return deferred.promise(); | |
} | |
function finish() { | |
console.log('done!'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works like a charm