Results 1 to 3 of 3

Thread: global variable defenition

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    28

    Default Answered: global variable defenition

    I was wondering what's the best place to define a global variable?

    At the moment in my Ext.application config i define a variable
    Code:
    apiUrls: (function() {
            var api_base = "http://base_url/";
            return {
                sub: {
                     thing: api_base + "sub/thing",
                    value: api_base + "sub/value"
                }
            };
        }())
    this way, when i define a store i can provide this variable to the proxy url

    Code:
    proxy: {
                url: MyApp.app.apiUrls.sub.thing,
                ...
    this works fine in development but when i want to build the file using the following line

    Code:
    sencha app build testing
    the Ext.application part gets put at the end of the file so when the browser is parsing my stores, it doesn't know the MyApp.app yet.


    So whats best practice for global variables?

  2. I usually use a full blown config utilty class.

    Check out this blog post, it's talking about something different but the subject is exactly what you need http://mitchellsimoens.com/2012/06/s...encha-command/

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    I usually use a full blown config utilty class.

    Check out this blog post, it's talking about something different but the subject is exactly what you need http://mitchellsimoens.com/2012/06/s...encha-command/
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    28

    Default

    Thx for explaining this, this helped alot.

Posting Permissions

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