PDA

View Full Version : initConfig and order dependencies



abierbaum
20 Mar 2012, 7:32 AM
I am using the new style class system and trying to determine how to handle order dependencies in the object configuration processing. For example take this object:



Ext.define('MyClass', {
config: {
paramA: null,
paramB: null
},

constructor: function(config) {
this.initConfig(config);
this.callParent(arguments);
},

applyParamA: function(value) {
b = this.getParamB();
return doWork(b);
},

applyParamB: function(value) {
return doSomething(value);
}
});


I have two configuration parameters. Param B initializes itself based upon some computation internal to the class. Param A needs to initialize itself but needs to use the initialized value of param B as part of this computation.

This creates an order dependency inside the initialization performed by initConfig. Namely param B must be initialized first so it is available for Param A to be initialized.

My question is, how do I handle this in my application. Is there some way to specify this? Does the class system try to automatically solve for these cases?

mitchellsimoens
20 Mar 2012, 7:41 AM
The apply methods will fire in the order you place them in the config object.

So if you have


config : {
paramA : true,
paramB : true
}

Then applyParamA will fire before applyParamB. However if you have


config : {
paramB : true,
paramA : true
}

Then applyParamB will fire before applyParamA