View Full Version : DelayedTask

24 Apr 2009, 2:27 AM
Anyone know why this fires a bizillion times:

var delaytask = new Ext.util.DelayedTask();

function init(a,b) {
console.log("init", a, b);
if (isReady()) {
; do some ready stuff
} else {
console.log("delaying task");
delaytask.delay(900, init(a,b));

No matter what I set the delay for - it fires continuously in firebug. I'm sure I'm missing something silly - it's been an allnighter!


24 Apr 2009, 2:31 AM
You are calling init(a, b), and passing the result from that call into delaytask.delay!

Obviously, you calling that recurses and does the same thing immediately.. etc....

Pass A Function, not the result of calling a Function.

24 Apr 2009, 2:42 AM
Thanks! See what 20 hours of straight coding does to your brain - very obvious...

What's the best way of repassing those parameters into the function?

24 Apr 2009, 2:45 AM
It requires a Function. Pass a Function. as in

function(){ perform the actions you want to perform}

24 Apr 2009, 2:47 AM
I tried that originally but left the parms in the function wrapper - just had to remove them and they instantiated inside...

I must definitely need some sleep - only another 8 hours more to go : )

24 Apr 2009, 2:56 AM
Thanks for the sanity check Animal!