1. #1
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Duluth, MN
    Posts
    126
    Vote Rating
    4
    badgerb1 is on a distinguished road

      0  

    Default SuperClass Properties shared between subclasses.

    SuperClass Properties shared between subclasses.


    Hi guys,

    Discovered this bit of weirdness and thought it should be documented in case anyone else is having strange issues like this.

    class A extends Model and has a variable prop1 and a method
    manipulateProp1:function(value){
    this.prop1 = value;
    }

    class B extends class A

    instantiate 2 of class B.
    var y = new B();
    y.manipulateProp1(23);

    var z = new B();

    z.prop1 == 23 //is true.

    Any properties defined in the superclass that are manipulated by the superclass wind up changing the values for all subclass instances. Weirdest part is that if the property is in the superclass but manipulated by the subclass methods then the values aren't shared.

    I'm probably missing something simple here but this seems to be what is happening for me.

    Thanks
    Bob

  2. #2
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Duluth, MN
    Posts
    126
    Vote Rating
    4
    badgerb1 is on a distinguished road

      0  

    Default Follow up info

    Follow up info


    This might be specifically Model classes.

    Also noticing that any new configs that are added are also shared by the instances. So ...

    Ext.define("myModel",
    extend:'Ext.data.Model',

    config:{
    prop2:null
    }

    applyProp2:function(newValue){
    console.log(newValue);
    },
    someMethod:function(value){

    this.setProp2(value);
    }


    Ext.define("myModel2", {
    extend:'myModel',
    }

    a = new myModel2();
    b = new myModel2();

    a.someMethod(22);

    applyProp2 gets run when the define is processed but not when the new model instances are created. Also, a.getProp2() == b.getProp2() is true.

    However,
    if I call a.setProp2(24) externally,
    a.getProp2() == b.getProp2() is false.

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