{ "id": "166409", "key": "AC-4834", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-03-03T14:11:56.000+0000", "created": "2017-03-03T09:58:01.000+0000", "labels": [ "alloy.js", "scope", "variables" ], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-03T14:11:56.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "Defining a *var* in alloy.js actually creates a \"global\" variable since the context is the app itself. One would expect to have any local variable here go out of scope.\r\n\r\n{code:javascript}\r\n// File: app/alloy.js\r\nvar mytestvar = 'foobar';\r\n{code}\r\n\r\nNext, open any controller or common.js module, and simply retrieve the variable using *console.log(mytestvar);*. It will exist forever during the app's runtime.\r\n\r\nI know one solution is to simply put alloy.js in a *(function(){})()* wrapper but the current implementation seems wrong by design.\r\n", "attachment": [], "flagged": false, "summary": "Defining var in Alloy.js causes global scope", "creator": { "name": "creative_jira_user", "key": "uzbbert", "displayName": "Creative", "active": false, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "creative_jira_user", "key": "uzbbert", "displayName": "Creative", "active": false, "timeZone": "Europe/Amsterdam" }, "environment": "Ti SDK 6.0.1.GA, Alloy 1.9.5, iOS+Android", "comment": { "comments": [ { "id": "408839", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "This is made by design. The alloy.js is meant to be global if needed (although not recommended). People usually store global modules instances like Ti.Map there.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-03-03T14:11:56.000+0000", "updated": "2017-03-03T14:11:56.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }