In node.js , I need to call a function as soon as a variable is changing.
so what I am doing right now is:
var globalvar = 0;
function abc(localvar) {
if (globalvar == 1) {
//some stuff
} else {
setTimeout(abc(localvar), 1000);
}
}
abc(localvar);
But my server crashes with "Maximum call stack size exceeded."
If I do setTimeout(function(){abc(localvar);}, 1000);
instead, will it work? (I can't test it right now)
How can I do?