Skip to content

Instantly share code, notes, and snippets.

@CarlLee
Last active August 29, 2015 11:57
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 CarlLee/66a667775fbd94802173 to your computer and use it in GitHub Desktop.
Save CarlLee/66a667775fbd94802173 to your computer and use it in GitHub Desktop.
checking multiple conditions asynchronously
var bools = {};
function check1(){
// do something
bools['check1'] = condition1;
finalChek();
}
function check2(){
// do other things
bool['check2'] = condition2);
finalCheck();
}
function finalCheck(){
if(bools['check1'] != undefined && bools['check2'] != undefined){
var finalBool = true;
for(var attr in bools){
finalBool &= bools[attr];
}
if(finalBool){
//all true
}else{
//at least one false
}
}
}
// start somthing async
async_function(check1);
async_function(check2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment