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

      0  

    Question initConfig and order dependencies

    initConfig and order dependencies


    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:

    Code:
    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?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    899
    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


    The apply methods will fire in the order you place them in the config object.

    So if you have

    Code:
    config : {
        paramA : true,
        paramB : true
    }
    Then applyParamA will fire before applyParamB. However if you have

    Code:
    config : {
        paramB : true,
        paramA : true
    }
    Then applyParamB will fire before applyParamA
    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.

Thread Participants: 1

Tags for this Thread