Skip to content

Instantly share code, notes, and snippets.

@shawiz
Created September 28, 2012 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawiz/3798898 to your computer and use it in GitHub Desktop.
Save shawiz/3798898 to your computer and use it in GitHub Desktop.
settimeout deferred
function foo(x) {
return (x === 10) || $.Deferred(function(d) {
window.setTimeout(function() {
console.log(x);
d.resolve(foo(x+1));
}, 1000);
}).promise();
}
foo(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment