1. #1
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Paris, France
    Posts
    187
    Vote Rating
    3
    Answers
    5
    olouvignes is on a distinguished road

      0  

    Default Unanswered: attach a mixin dynamically ?

    Unanswered: attach a mixin dynamically ?


    Is there a way to attach a mixin to a class after it has been created (or inside its constructor from options)?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    436
    Answers
    3113
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Yes, you can technically but we recommend that you have it at class creation and then you can execute methods on that mixin later on.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

  3. #3
    Sencha - Sencha Touch Dev Team Jacky Nguyen's Avatar
    Join Date
    Jul 2009
    Location
    Palo Alto, California
    Posts
    469
    Vote Rating
    9
    Answers
    24
    Jacky Nguyen will become famous soon enough Jacky Nguyen will become famous soon enough

      0  

    Default


    You certainly could if absolutely needed using the static 'mixin' method that exists in every class. For example:

    Code:
    Ext.define('A', {
        foo: true
    });
    
    Ext.define('B', {
        bar: true
    });
    
    A.mixin('b', B);
    Note that this is currently a private API, hence it's still subject to change.
    Sencha Touch Lead Architect

  4. #4
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Paris, France
    Posts
    187
    Vote Rating
    3
    Answers
    5
    olouvignes is on a distinguished road

      0  

    Default


    Hum, seems to fit my needs but i can't make it work :

    Code:
    Ext.define('Ext.i18n.Locale', {
    
    
        extend: 'Ext.Base',
    
    
        mixins: ['Ext.util.Observable'],
    
    
        constructor: function(config) {
    
    
            // Merge defaults
            this.config = Ext.Object.merge(this.config, config);
    
    
            // Load mixins
            _.each(this.config.mixins, function(value, key) { Ext.i18n.Locale.mixin(value, Ext.ClassManager.get(value)); });