1. #1
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Paris, France
    Posts
    187
    Answers
    5
    Vote Rating
    3
    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
    Gainesville, FL
    Posts
    37,073
    Answers
    3500
    Vote Rating
    853
    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


    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
    ________________
    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 User Jacky Nguyen's Avatar
    Join Date
    Jul 2009
    Location
    Palo Alto, California
    Posts
    469
    Answers
    24
    Vote Rating
    14
    Jacky Nguyen has a spectacular aura about Jacky Nguyen has a spectacular aura about

      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
    Answers
    5
    Vote Rating
    3
    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)); });