Skip to content

Instantly share code, notes, and snippets.

@mkuklis
Created March 15, 2012 20:28
Show Gist options
  • Save mkuklis/2046692 to your computer and use it in GitHub Desktop.
Save mkuklis/2046692 to your computer and use it in GitHub Desktop.
playing with deferred objects
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