Hi All,
Any of you have recommendations or best practice for code re-use on frequently (but not universally) used fields in data models?
I'm aware that common fields can be placed in a base model and then used in extended models, but that's often overly simplistic - what if only a few of the extended models require a certain set of fields.
I thought of using mixins to the Ext.data.Model, but can't seem to push the additional field definitions in time:
Code:
Ext.define('MyApp.models.MixZ', {
extend: 'Ext.Mixin',
mixinConfig: {
before: {
constructor: 'addFields'
}
},
addFields: function(){
Ext.Array.push(this.fields, ['mixFieldZ1', 'mixFieldZ2']);
}
});
Ext.define('MyApp.models.ModelA', {
extend: 'Ext.data.Model',
mixins: {
mixZ: 'MyApp.models.MixZ'
},
fields: [ 'field1', 'field2']
});
Any suggestions?