1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    19
    Vote Rating
    0
    fenderico is on a distinguished road

      0  

    Default Answered: How to define global config for a sencha app

    Answered: How to define global config for a sencha app


    Hello everybody,

    I'd like to know which's the way to define global configuration to be used from the Controllers and Views. Is there any 'sencha-way' to do so? or should I use just simple javascript global variables which is not, I know, the best way?

    Thanks in advance,

  2. What I do is have a singleton class..

    Code:
    Ext.define('MyApp.util.Config', {
        singleton : true,
    
        config : {
            foo : 'bar'
        }
    });
    Then you can do

    Code:
    MyApp.util.Config.getFoo();

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    34,121
    Vote Rating
    453
    Answers
    3160
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    What I do is have a singleton class..

    Code:
    Ext.define('MyApp.util.Config', {
        singleton : true,
    
        config : {
            foo : 'bar'
        }
    });
    Then you can do

    Code:
    MyApp.util.Config.getFoo();
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    19
    Vote Rating
    0
    fenderico is on a distinguished road

      0  

    Default


    thank you for your quick response!

  5. #4
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    88
    Vote Rating
    3
    Answers
    3
    whirling dervish is on a distinguished road

      0  

    Default


    Sorry to bring this thread back from the dead but I have a follow up question.

    Is using a singleton object to store variables preferable to using a namespace for the same purpose?

  6. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    17
    Vote Rating
    0
    acorotchi is on a distinguished road

      0  

    Default Sencha 2.1 andCmd 3.0 config issue

    Sencha 2.1 andCmd 3.0 config issue


    Hi guys, I used this class as well for my app config, but when I upgrade my sencha I have issue when I try to build production and I have not idea what is the issue :

    Code:
    TypeError: Object #<Object> has no method 'define'

    Is someone having the same issue, or do you know a fix bu change.

    Thanks in advice .

  7. #6
    Sencha User
    Join Date
    Mar 2012
    Location
    China
    Posts
    10
    Vote Rating
    -1
    youngshine is an unknown quantity at this point

      0  

    Default