[TIMOB-14721] LiveView: App.js Lexical Scope local vars not globally available
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-08-07T01:40:50.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2013 Sprint 16, 2013 Sprint 16 Tooling, Release 3.1.3, Release 3.2.0 |
Components | LiveView |
Labels | qe-closed-3.2.0 |
Reporter | Christian Sullivan |
Assignee | Christian Sullivan |
Created | 2013-07-31T21:09:21.000+0000 |
Updated | 2014-01-02T09:23:35.000+0000 |
Description
Variable defined in the
app.js
are not globally available. This is due to the project's app.js being executed outside of first loaded app.js context.
TEST Normal
1) Create app with code snippets below
2) Build app
Result: console will output 'Lex Scope Var'
TEST Liveview
1) Create app with code snippets below
2) Build app with --liveview flag
Expected Result: console will output 'Lex Scope Var'
Actual Result: error due to lexvar not being defined
Example Code
//app.js
var lexvar = 'Lex Scope Var';
var require('test');
//test.js
console.log(lexvar);
From Tony: To get around this issue, developers would need to explicitly re-require Alloy:
And there's also underscore(_) and Backbone to worry about as well. Those require statements are part of every Alloy-generated controller, but anything in the developer's "lib" or "assets" folder I have no control over. In those situations developers are relying on the global presence of Alloy. And they do it a lot, as it was one of the most asked Q&A questions until Android made them global as well.
Added support for injecting local lexical scope vars in user's app.js in to the project's 'Global' context https://github.com/euforic/liveview/tree/bug/TIMOB-14721
[~csullivan] I'm getting a 404 when clicking on the link. Is the branch pushed to remote yet?
It's already part of master.
Re-opening as running Field Service app is showing the following error:
fixed in [master] https://github.com/appcelerator/liveview/commit/d0901508657d4c11479cddb4a050574069f99076 Released in version 0.1.30 https://github.com/appcelerator/liveview/releases/tag/0.1.30
Verified with test Environment: Appc-Studio: 3.2.0.201312191455 Sdk:3.2.0.GA acs:1.0.11 alloy:1.3.0 npm:1.3.2 titanium:3.2.0 titanium-code-processor:1.1.0 Osx: Maverick 10.9 Xcode: xCode 5.0.2 Device: Google Nexus7(v4.4.2),Iphone Simulator(v7.0.3) Getting the required console logs with both liveView enabled and disabled. Hence alosing as fixed and Verified.