Results 1 to 2 of 2

Thread: Observable.fire - behaviour changed.

  1. #1
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,607
    Vote Rating
    59
      0  

    Default Observable.fire - behaviour changed.

    In the old code, Observable.fireEvent used fireDirect which looked like this:

    Code:
    YAHOO.util.CustomEvent.prototype.fireDirect = function(){
        var len=this.subscribers.length;
        for (var i=0; i<len; ++i) {
            var s = this.subscribers[i];
            if(s){
                var scope = (s.override) ? s.obj : this.scope;
                if(s.fn.apply(scope, arguments) === false){
                    return false;
                }
            }
        }
        return true;
    };
    See that if the handler does not explicitly return false the event firing code returns true, and if you write your Observable subclass so that handlers may veto the operation by explicitly returning false - your code will still execute if no return statement is executed.

    The new code is:

    Code:
            fire : function(){
                var args = Array.prototype.slice.call(arguments, 0);
                var ls = this.listeners, scope;
                for(var i = 0, len = ls.length; i < len; i++){
                    var l = ls[i];
                    if(l.fireFn.apply(l.scope, arguments) === false){
                        return false;
                    }
                }
            }
    It just needs "return true;" adding to the end!

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    6,956
    Vote Rating
    20
      0  

    Default

    I added it. Personally, I always check === or !== but I am paranoid.

Similar Threads

  1. Ext 1.0 Grid Scrollbar Changed
    By griffiti93 in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 10 Mar 2007, 11:18 PM
  2. fire onclick but not ondrag
    By Slapyo in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 29 Nov 2006, 11:11 PM
  3. I'm so glad I changed hosts
    By jack.slocum in forum Community Discussion
    Replies: 17
    Last Post: 19 Nov 2006, 8:49 AM
  4. 3 Weeks on Mr. Jack's yui-ext and web-dev is changed forever
    By christocracy in forum Community Discussion
    Replies: 15
    Last Post: 2 Nov 2006, 2:18 AM

Posting Permissions

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