Results 1 to 2 of 2

Thread: initConfig and order dependencies

  1. #1
    Ext JS Premium Member
    Join Date
    Oct 2010
    Posts
    103
    Vote Rating
    7
      0  

    Question 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,551
    Vote Rating
    1271
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •