Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-15009

LiveView: cannot see Alloy.Globals in modules when using LiveView

    Details

    • Story Points:
      13

      Description

      Problem description

      When using LiveView, the global variable Alloy.Globals is not defined in modules. Disabling LiveView would not throw the error.

      Code to reproduce

      Create an Alloy app with this code:

      index.js

      var win = Ti.UI.createWindow({
          backgroundColor:'#ffffff'
      });
       
      Ti.API.info(Alloy.Globals.test);
       
      var Test = require('test');
      new Test();
       
      win.open();
      

      lib/test.js

      function Test() {
      	Ti.API.info(Alloy.Globals.test);
      };
       
      module.exports = Test;
      

      Add the global variable in alloy.js:

      Alloy.Globals.test = "TEST";
      

      Actual behavior

      When running the app with LiveView on, the following error is thrown:

      [INFO] :   [LiveView] Error Evaluating app.js @ Line: 2
      [ERROR] :  TypeError: 'undefined' is not an object (evaluating 'Alloy.Globals')
      [ERROR] :  File: app.js
      [ERROR] :  Line: 2
      [ERROR] :  SourceId: 323744256
      [ERROR] :  Backtrace:
      [ERROR] :   #0 Controller() at :21
      [ERROR] :  #1 () at :214
      [ERROR] :  #2 anonymous() at :15
      [ERROR] :  #3 () at file://localhost/Users/dcassenti/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/4822E77B-90A1-4555-8E22-DA55E5976F16/DavideAlloyTestApp.app/app.js:628
      [ERROR] :  #4 () at file://localhost/Users/dcassenti/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/4822E77B-90A1-4555-8E22-DA55E5976F16/DavideAlloyTestApp.app/app.js:493
      [ERROR] :  #5 () at file://localhost/Users/dcassenti/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/4822E77B-90A1-4555-8E22-DA55E5976F16/DavideAlloyTestApp.app/app.js:460
      [ERROR] :  #6 () at file://localhost/Users/dcassenti/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/4822E77B-90A1-4555-8E22-DA55E5976F16/DavideAlloyTestApp.app/app.js:392
      [ERROR] :  #7 () at file://localhost/Users/dcassenti/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/4822E77B-90A1-4555-8E22-DA55E5976F16/DavideAlloyTestApp.app/app.js:663
      

      Without LiveView, the error is not shown. Note that in index.js the error is not thrown.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                csullivan Christian Sullivan
                Reporter:
                dcassenti Davide Cassenti
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-17312
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration