1. #1
    Ext User
    Join Date
    Jun 2009
    Posts
    12
    Vote Rating
    0
    andyatmiami is on a distinguished road

      0  

    Default Why is scope declared in Ext.util.Event fire() method?

    Why is scope declared in Ext.util.Event fire() method?


    Below is the source code. I am a newbie in Ext (and more or less in javascript). I have been doing some extensive reading and trying to follow through the Ext source code, but I can't understand why scope is declared in this method when it never gets initialized nor used...

    Can anyone explain this behavior to me?

    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||this.obj||window, arguments) === false){
    this.firing = false;
    return false;
    }
    }
    this.firing = false;
    }
    return true;
    }

  2. #2
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Quote Originally Posted by andyatmiami View Post
    Below is the source code. I am a newbie in Ext (and more or less in javascript). I have been doing some extensive reading and trying to follow through the Ext source code, but I can't understand why scope is declared in this method when it never gets initialized nor used...

    Can anyone explain this behavior to me?

    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||this.obj||window, arguments) === false){
    this.firing = false;
    return false;
    }
    }
    this.firing = false;
    }
    return true;
    }


    Seems like you're a newb to posting code in forums too
    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||this.obj||window, arguments) === false){
                            this.firing = false;
                            return false;
                        }
                    }
                    this.firing = false;
                }
                return true;
            }
    Scope is not being declared, but rather referenced.

    if(l.fireFn.apply(l.scope||this.obj||window, arguments) === false){

    Basically, in English this means:

    if listener's method.apply return is equal to the value of and data type of false.

    Inside the apply call, there are two parameters being passed.

    The first is scope, and the second is arguments.

    Break down the scope, it's either listener.scope, this.object or ultimately window.

    Does this help/

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,499
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    The OP is correct. There is an unreferenced var declaration:

    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||this.obj||window, arguments) === false){
                            this.firing = false;
                            return false;
                        }
                    }
                    this.firing = false;
                }
                return true;
            }
    This still exists in the 2.* code, not the 3.0

  4. #4
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Yup missed it.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi