Created
March 27, 2012 05:27
-
-
Save nike-17/2212777 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
var state = { | |
one: false, | |
two: false | |
}; | |
// Task | |
var parallelTaskHandler = function(){ | |
// Check for success | |
if (state.one && state.two) { | |
// Callback | |
function(){ | |
//do | |
//deal with task | |
} | |
} | |
}; | |
// First | |
request({ | |
success: function(data) { | |
state.one = data; | |
parallelTaskHandler(); | |
} | |
}); | |
// Second | |
request({ | |
success: function(data) { | |
state.two = data; | |
parallelTaskHandler(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment