So I was messing around with google's hangouts api and there is a function called addStateChangeListener( callback ) which allows you to register a callback function that will be called whenever the state of the application changes.
An example callback function that could be registered is
function onStateChanged(add, remove, state, metadata) {
state_ = state;
metadata_ = metadata;
if (<some boolean>) {
doFunction(); //this function alters the state
}
//more stuff below
}
My question is: If doFunction() did something that altered the state, (and triggered the addStateChangeListener) would onStateChange be called again before the rest of function after the if statement ran? Or would the first iteration of onStateChange() run to its completion first and then onStateChange would get called again. Or would it possibly just completely ignore the rest of the first onStateChange function, and just recall onStateChange when doFunction changes the state?
Thanks for your help.