Skip to content

Instantly share code, notes, and snippets.

@OfTheDelmer
Created October 7, 2013 23:09
Show Gist options
  • Save OfTheDelmer/6876572 to your computer and use it in GitHub Desktop.
Save OfTheDelmer/6876572 to your computer and use it in GitHub Desktop.
<script>
function doSomething(){
var todo = $.Deferred();
$.when("")
.then(function(){
setTimeout(function(){
alert("Our First Thing is Done!!")
}, 500)
})
.then(function(){
setTimeout(function(){
todo.resolve("Our whole promise is done!");
}, 5000)
})
return todo.promise();
}
var aboutTo = doSomething().done(function(msg){ alert(msg)});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment