{ "id": "146387", "key": "ALOY-1259", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2015-03-30T17:46:01.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [ { "id": "16595", "name": "Alloy 1.5.1", "archived": false, "released": true, "releaseDate": "2014-10-01" }, { "id": "16692", "name": "Alloy 1.7.0", "archived": false, "released": true, "releaseDate": "2015-07-22" } ], "issuelinks": [], "assignee": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "updated": "2015-07-09T14:48:33.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [], "description": "The code a developer adds to {{app/alloy.js}} will simply be injected into the generated {{Resources//app.js}} file as can be seen in the [template|https://github.com/appcelerator/alloy/blob/master/Alloy/template/app.js].\r\n\r\nUnlike the CommonJS modules that make up the rest of an Alloy app, all variables in this file will be part of the global scope.\r\n\r\nWe could enforce a best practice to not pollute the global scope by wrapping the imported code in a self-executing function like this:\r\n\r\n{code:javascript}\r\n(function(exports) {\r\n\t\r\n__MAPMARKER_ALLOY_JS__\r\n\t\r\n})(this);\r\n{code}\r\n\r\nThis way, the developer can still force to set a global by using {{exports.foo = \"bar\";}} just like they export variables in controllers.\r\n\r\nh1. Warning\r\nThis **will** break apps that depend on globals set in {{alloy.js}}, other then those using {{Alloy.Globals}}.", "attachment": [], "flagged": false, "summary": "Alloy: The code in alloy.js should be wrapped by app.js to protect global scope", "creator": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "master", "comment": { "comments": [ { "id": "347739", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "PR on master: https://github.com/appcelerator/alloy/pull/675", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-03-30T17:46:48.000+0000", "updated": "2015-03-30T17:46:48.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }