Results 1 to 4 of 4

Thread: Production built and singleton requirement

  1. #1
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Paris
    Posts
    116
    Answers
    2

    Default Production built and singleton requirement

    Hi everybody.

    I have an issue with the production built. Others ares ok.
    In my app.js, I have this :
    Code:
    Ext.application({    name: 'MyApp',
    
    
    
    
        requires:
        [
            'MyApp.util.Config',
            'Ext.MessageBox',
            'MyApp.view.Main',
            'Ext.data.proxy.LocalStorage'
        ],
    ...
    and this file contains
    Code:
    Ext.define('MyApp.util.Config',
    {
    	singleton  : true,
    	config     :
        {
    
            apiUrl                  : 'http://www.myapp.dev/',
    ...
    Lots of store or controllers use this
    Code:
     MyApp.util.Config.getApiUrl():
    But in production built, it seems that this file is not loaded before use or anything like this.
    I have checked the app.js from prod and the file is included.
    But when I launch the prod app, it fails
    Error evaluating http://www.myapp.dev/build/production/MyApp/app.js with message: TypeError: Cannot read property 'getApiUrl' of undefined
    Does anyone has a clue on this ?
    I certainly missed a litlle configuration.

    Thx.

    Sylvain

  2. #2
    Sencha User dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,748
    Answers
    55

    Default

    If class A is needed by class B, class B should add a "requires" for A. Otherwise the order is technically "unspecified". Adding a requires for A in app.js only ensures that the file will be in the build and that it should come before app.js.
    Don Griffin

    "Use the source, Luke!"

  3. #3
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Paris
    Posts
    116
    Answers
    2

    Default

    Thanks for the answer.So I should call my file before app.js ?But how could I manage this ?

  4. #4
    Sencha User dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,748
    Answers
    55

    Default

    Instead of using "requires" in app.js you should use "requires" in the stores and controllers that actually need the utility class. That will ensure the order you need.
    Don Griffin

    "Use the source, Luke!"

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
  •