1. #1
    Sencha User
    Join Date
    Jun 2009
    Posts
    60
    Vote Rating
    0
    kchiu is on a distinguished road

      0  

    Default Best practice for custom component properties?

    Best practice for custom component properties?


    Hi there,

    What's the suggested location for storing extra properties for custom components defined via Ext.define()? Where should we store these extra properties without clashing with any existing / future properties of the Component we're extending?

    eg. given the code below, where should I store the 'map' property used by redrawMap()? And for that matter, should redrawMap() be nested under a property specifically for holding all other custom properties?

    cheers.

    Code:
       Ext.define('VVG.view.MapView', {
          alias : 'widget.mapview',
          extend: 'Ext.container.Container',
          requires: ['Ext.container.Container']
          
          ,afterComponentLayout : function() {
             this.redrawMap();
             this.callParent(arguments);
          }
          
          ,redrawMap: function() {
             var map = this.map;
             if(!map) {
                this.map = vvg.lib.createMap(this.getId());
             } else {
                // probably redundant
                map.render(this.getId());
    
    
                // required
                for (var i = 0; i < map.layers.length; i++) {
                   if(map.layers[i].getVisibility() === true)
                      map.layers[i].redraw();            
                }
             }
          }
       });

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,572
    Vote Rating
    307
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Storing them directly on this is fine. Yes, there's a risk your properties could clash with the superclass but in practice it happens very rarely and it isn't worth throwing in extra complexity to avoid it. Generally I try to stay clear of generic property names like map to reduce the chances of a clash but that's about it.

    The most common source of problems along these lines is event handlers. I tend to put the suffix Handler on mine to make sure I don't clash with the library's template methods.

Thread Participants: 1

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..."