I was thinking that having a function with variables and methods would be able to allow the subfunctions to reference the variables. Maybe I am doing it wrong, and would like some advice on how to properly fomat this stuff.
function somefunction(callback) {
var x,y,z;
var timervar = setInterval(function() {
//...
callback().always(function() {
x++;
});
//...
}, 1);
}
How would i properly relate the X?
Edit:
I am doing some iteration within a while loop. x,y,z are variables which are to store counter information. I was more or less incremementing or decremementing a variable when callback finished execution.
The reason why it isnt calling more callback() is because it is in while loop. WHich is fine and dandy as it is related to the X value. It seems that after a certain point, it exits the scope of the while loop and waits for .always() to be fired off so it would then be able to resume the while loop. The while loop is set within the timer, so it checks every 10ms if it is ready to keep looking.
Final Edit: always wasnt firing because i forgot the return in callback() so it was never recognized as finished. ._.