1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,307
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default AbstractComponent - can I override the onDestroy method?

    AbstractComponent - can I override the onDestroy method?


    Can a subclass override the AbstractComponent.onDestroy method? ... or is this method private and should I override the beforeDestroy method instead?

    Code:
    Ext.define('Ext.AbstractComponent', {
        ...
        /**
         * Invoked before the Component is destroyed.
         *
         * @method
         * @template
         * @protected
         */
        beforeDestroy : Ext.emptyFn,
        ...
        onDestroy : function() {
            ...
        },
        ....
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Any subclass can override it but it does a few things that you would need to clean up. I would just do a callParent
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    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


    Personally I wouldn't hesitate to override onDestroy if I needed to add destruction logic to a custom component. Choosing between onDestroy and beforeDestroy seems to be just a matter of timing.

    Methods with names that sound like events (e.g. onDestroy, afterRender) are to be thought of as 'internal events', intended to be overridden in subclasses. Of course you have to take care to call the overridden method at the appropriate time.

    There are some really old posts that you may find interesting. Here's one from Jack Slocum explaining his use of template methods in ExtJS 1. This principle remains in the current framework:

    http://www.sencha.com/forum/showthre...ll=1#post33312

    Later in the same thread he touches upon why he chose to name some methods after events:

    http://www.sencha.com/forum/showthre...ll=1#post33652

    This blog post from Nige White also touches upon this subject. Most of the post is about writing plugins but if you skim down you'll find he discusses some of the template methods in the framework:

    http://www.sencha.com/blog/advanced-...t-with-ext-js/

    He also explains some of the reasons why overriding methods is more appropriate than listening to events when writing an extension.

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