Skip to content

Instantly share code, notes, and snippets.

@panphora panphora/deferred
Last active Dec 22, 2015

Embed
What would you like to do?
simple jquery deferred example
var bringMeToast = function () {
var d = new $.Deferred();
setTimeout(function () {
d.resolve()
}, 2000);
return d;
};
var bringMeASwartwouter = function () {
var d = new $.Deferred();
setTimeout(function () {
d.resolve()
}, 5000);
return d;
};
$.when(bringMeToast(), bringMeASwartwouter()).then(function () {
console.log('mm delicious swartwouter on toast'); // get this after 5 seconds
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.