Created
March 15, 2012 20:28
-
-
Save mkuklis/2046692 to your computer and use it in GitHub Desktop.
playing with deferred objects
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
var a = function () { | |
var obj = $.Deferred(); | |
setTimeout(function () { | |
console.log('resolving a'); | |
obj.resolve({a: 1}); | |
}, 1000); | |
return obj; | |
} | |
var b = function () { | |
var obj = $.Deferred(); | |
setTimeout(function () { | |
console.log('resolving b'); | |
obj.resolve({b: 2}); | |
}, 2000); | |
return obj; | |
} | |
var c = function () { | |
var obj = $.Deferred(); | |
setTimeout(function () { | |
console.log("resolving c"); | |
obj.resolve({c: 3}); | |
}, 3000); | |
return obj; | |
} | |
$.when(c()).pipe(b).then(a); | |
// resolving c | |
// resolving b | |
// resolving a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment