1. #1
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    23
    Answers
    1
    Vote Rating
    1
    byu_risk3 is on a distinguished road

      0  

    Default Unanswered: How to tell if DelayedTask currently has a pending task

    Unanswered: How to tell if DelayedTask currently has a pending task


    So, I have a DelayedTask set up, and I want to know if there is currently a pending delay() task.

    For argument's sake...
    Code:
    myFunction = function(){ console.log( "Hello" ) };
    myDelay = new Ext.util.DelayedTask( myFunction );
    myDelay.delay( 100000 );
    // How do I know if myDelay has a pending task??
    With this code, how do I know if myDelay has a currently pending task?

    I could set a global flag, but I was wondering if there was a more encapsulated solution out there.

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,770
    Answers
    355
    Vote Rating
    165
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    I'm not seeing a very straight-forward way of doing this with the Ext.util.DelayedTask without extending it. Would a TaskRunner instance work as well for you? There is an undocumented 'pending' property that is set as the task is in motion.

    Code:
    var filterPanel = Ext.create('Ext.panel.Panel', {
        bodyPadding: 5,  // Don't want content to crunch against the borders
        width: 300,
        height: 100,
        title: 'Filters',
        dockedItems: [{
            xtype: 'toolbar'
            , items: [{
                text: 'Timer'
                , handler: function (btn) {
                    var panel = btn.up('panel');
                    
                    panel.update('Timer Started');
                    
                    if (!panel.timer) {
                        /*panel.timer = new Ext.util.DelayedTask(function(){
                            panel.update('Timer Finished');
                        });*/
                        var runner = new Ext.util.TaskRunner();
                        panel.timer = runner.newTask({
                            run: function () {
                                panel.update('Timer Finished');
                            },
                            interval: 5000
                            , repeat: 1
                        });
                    }
                    
                    //panel.timer.delay(10000); // ten seconds
                    panel.timer.start();
                }
            }, {
                text: 'Active?'
                , handler: function (btn) {
                    var panel = btn.up('panel');
                    
                    if (panel.timer) {
                        console.log(panel.timer.pending);
                    }
                }
            }]
        }],
        renderTo: Ext.getBody()
    });

  3. #3
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    23
    Answers
    1
    Vote Rating
    1
    byu_risk3 is on a distinguished road

      0  

    Default


    Thanks for the input.

    For my app, I am using a DelayedTask in response to a user initiated event, not a repeated task I want to do. So, I don't know if TaskRunner will help me much (there doesn't seem to be a 'task.cancel()' function once the user satisfies some condition, for example).

    Also, in general I think it would be better practice and safer to just use my own global flag instead of rely on undocumented properties that are not guaranteed to be constant.

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar