Results 1 to 6 of 6

Thread: DelayedTask

  1. #1
    Ext User
    Join Date
    Aug 2008
    Posts
    43

    Default DelayedTask

    Anyone know why this fires a bizillion times:

    Code:
    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!

    Thanks.

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    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.

  3. #3
    Ext User
    Join Date
    Aug 2008
    Posts
    43

    Default LOL

    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?

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    It requires a Function. Pass a Function. as in

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

  5. #5
    Ext User
    Join Date
    Aug 2008
    Posts
    43

    Default Yes...

    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 : )

  6. #6
    Ext User
    Join Date
    Aug 2008
    Posts
    43

    Default Sanity Check

    Thanks for the sanity check Animal!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •