1. #1
    Ext User papasi's Avatar
    Join Date
    Mar 2007
    Posts
    129
    Vote Rating
    0
    papasi is on a distinguished road

      0  

    Default Ext.util.Event.fire()

    Ext.util.Event.fire()


    Code:
    fire : function(){
        var ls = this.listeners, scope, len = ls.length;
        if(len > 0){
            this.firing = true;
            var args = Array.prototype.slice.call(arguments, 0);
            for(var i = 0; i < len; i++){
                var l = ls[i];
                if(l.fireFn.apply(l.scope, arguments) === false){
                    return false;
                }
            }
            this.firing = false;
        }
        return true;
    }
    If one of the listerners return false, this.firing = true is not reset to false, is this ok?

    Thanks

  2. #2
    Ext User papasi's Avatar
    Join Date
    Mar 2007
    Posts
    129
    Vote Rating
    0
    papasi is on a distinguished road

      0  

    Default


    It's just a minor detail. I see that this.firing is a flag for add/remove listerner method to tell if it can just slice the listerner array or make a copy first.

    One question though, since javascript is single threaded, why is this necessary?

    Thanks.

  3. #3
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    That is indeed an oversight. Thanks for pointing it out.

    The reason for the flag is because a listener can remove itself in the handler call (e.g. a 1 time listener) and break the loop.

Similar Threads

  1. how to stop click event when having dblclick event
    By seldon in forum Ext 1.x: Help & Discussion
    Replies: 5
    Last Post: 8 Nov 2011, 12:31 AM
  2. Observable.fire - behaviour changed.
    By Animal in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 23 Feb 2007, 7:19 AM
  3. Fire clear event when Store is empty?
    By aconran in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 22 Feb 2007, 4:39 PM
  4. struggle on event fire
    By qiuyl in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 9 Dec 2006, 3:25 PM
  5. fire onclick but not ondrag
    By Slapyo in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 29 Nov 2006, 11:11 PM

Thread Participants: 1