Created
April 25, 2013 14:02
-
-
Save moroya/5459946 to your computer and use it in GitHub Desktop.
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
// first | |
function first() { | |
var df = $.Deferred(); | |
setTimeout(function(){ | |
console.log('first'); | |
df.resolve(); | |
}, 1000); | |
return df.promise(); | |
} | |
// first (not async) | |
function second() { | |
var df = $.Deferred(); | |
console.log('second'); | |
return df.resolve(); | |
} | |
// third | |
function third() { | |
var df = $.Deferred(); | |
setTimeout(function(){ | |
console.log('third'); | |
df.resolve(); | |
}, 1000); | |
return df.promise(); | |
} | |
// fire! | |
first().done(function(){ | |
second().done(function(){ | |
third().done(function(){ | |
console.log('end'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment