I have the following example code – the first part can result in an async call or not – either way it should continue. I cannot put the rest of the code within the async callback since it needs to run when condition is false. So how to do this?
if(condition) {
someAsyncRequest(function(error, result)) {
//do something then continue
}
}
//do this next whether condition is true or not
I assume that putting the code to come after in a function might be the way to go and call that function within the async call above or on an else call if condition is false – but is there an alternative way that doesn’t require me breaking it up in functions?
Just declare some other function to be run whenever you need it :