Hybrid View

  1. #1
    Ext JS Premium Member
    Join Date
    Oct 2010
    Posts
    103
    Vote Rating
    7
    abierbaum is on a distinguished road

      0  

    Default Unanswered: Documentation for mixins?

    Unanswered: Documentation for mixins?


    Is there documentation for how to use mixins? I have a situation where I think I want to use a mixin, but I can't find any documentation that tells me exactly how to do it or how it functions.

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    416
    Vote Rating
    18
    Answers
    5
    jweber will become famous soon enough

      0  

    Default


    Here's a quick example (based on my reading of Sencha's code; I agree that we could use more documentation here):

    Code:
    Ext.define('MyMainClass', {
    	// the benefit is that you can add to your class with one
    	// or more mixins, rather than by extending another class
    	extend: 'MyParentClass',
    	mixins: {
    		myMixinIdentifier: 'MyMixinClass'
    	},
    	constructor: function(config) {
    		this.callParent(arguments);
    		// make sure you call this if your mixin has a constructor
    		this.mixins.myMixinIdentifier.constructor.call(this);
    	}
    });
    
    Ext.define('MyMixinClass', {
    	extend: 'Ext.mixin.Mixin',
    	mixinConfig: {
    		id: 'myMixinIdentifier'
    	},
    	config: {
    		// configs defined here will be added to MyMainClass instances
    	}
    	// methods defined here will be added to MyMainClass instances
    });

  3. #3
    Ext JS Premium Member
    Join Date
    Oct 2010
    Posts
    103
    Vote Rating
    7
    abierbaum is on a distinguished road

      0  

    Default


    Thanks for the quick reply. This is exactly what I wanted to see.

  4. #4
    Sencha User
    Join Date
    Mar 2013
    Location
    Shanghai China
    Posts
    1
    Vote Rating
    0
    Brooklyn Ji is on a distinguished road

      0  

    Default


    it is also helpful for me, thanks.

Thread Participants: 2

Tags for this Thread