F
foldface
Hi
This might be a bit tricky.
I want to call a method of a class using the setTimeout code, ok, can do this
like this:
var instance = this;
timerID = window.setTimeout( function() { instance.Method(); }, 1000);
Now I want to call a method a number of times from with the class and when they
have all finished I want a second method to be called, I don't want the methods
themselves to be altered, i.e. I want this to be generic.
Here was my idea:
var timerCounter = 0
function CallFunc(func, callbackFunc)
{
timerCounter--;
if(timerCounter == 0)
{
callbackFunc()
}
}
function DoAsyncRequest(func, callbackFunction)
{
timerCounter++;
return window.setTimeout( CallFunc(func, callbackFunction), 1);
}
You would call this using something like:
timerId = DoAsyncRequest(this.method(), this.method2());
How could I do this, tryed using eval to no avail. I just don't know the
language well enough yet.
Any ideas? Example code would be worth a million words please
Ta
F
This might be a bit tricky.
I want to call a method of a class using the setTimeout code, ok, can do this
like this:
var instance = this;
timerID = window.setTimeout( function() { instance.Method(); }, 1000);
Now I want to call a method a number of times from with the class and when they
have all finished I want a second method to be called, I don't want the methods
themselves to be altered, i.e. I want this to be generic.
Here was my idea:
var timerCounter = 0
function CallFunc(func, callbackFunc)
{
timerCounter--;
if(timerCounter == 0)
{
callbackFunc()
}
}
function DoAsyncRequest(func, callbackFunction)
{
timerCounter++;
return window.setTimeout( CallFunc(func, callbackFunction), 1);
}
You would call this using something like:
timerId = DoAsyncRequest(this.method(), this.method2());
How could I do this, tryed using eval to no avail. I just don't know the
language well enough yet.
Any ideas? Example code would be worth a million words please
Ta
F