{ "id": "131185", "key": "ALOY-1037", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [], "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2014-10-06T19:51:34.000+0000", "created": "2014-06-03T17:37:52.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [], "issuelinks": [ { "id": "41936", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "133434", "key": "ALOY-1092", "fields": { "summary": "Allow more query options / scope in .tss", "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" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } } ], "assignee": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "updated": "2014-10-06T19:51:50.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": "12329", "name": "Runtime", "description": "Generic bucket for uncategorized runtime issues" } ], "description": "Expose the controller name and parameters passed to Alloy.createController() so that they can be accessed later on.\r\n\r\nFor instance:\r\n\r\n{code}\r\nvar w = Alloy.createController(\"userProfile\", {\r\n\tuserId: 1234\r\n});\r\n\r\nvar controller = w.controllerPath; // \"userProfile\"\r\nvar arguments = w.controllerArguments; // { \"userId\": 1234 }\r\n{code}", "attachment": [], "flagged": false, "summary": "Expose instantiation arguments of createController", "creator": { "name": "matthewcongrove", "key": "matthewcongrove", "displayName": "Matthew Congrove", "active": true, "timeZone": "America/Chicago" }, "subtasks": [], "reporter": { "name": "matthewcongrove", "key": "matthewcongrove", "displayName": "Matthew Congrove", "active": true, "timeZone": "America/Chicago" }, "environment": null, "comment": { "comments": [ { "id": "307383", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "A couple of quick thoughts:\r\n\r\n1. You should already have access to these values already in whatever controller instantiates the new child controller. What does this new feature add? This would be just as valid as your sample:\r\n\r\n{code}\r\nvar childController = 'userProfile';\r\nvar userId = 1234;\r\n\r\nvar w = Alloy.createController(childController, { userId: userId});\r\n\r\n// then use childController and userId as needed instead of \r\n// controller or arguments\r\n{code}\r\n\r\n2. Making these arguments accessible will cause some confusion -- are they mutable values? If I change w.controllerArguments.userId would my child view update? What if I change w.controllerPath? \r\n\r\n3. Isn't there at least some minimal risk of increased memory use or leaks by adding references to variables you already reference elsewhere? Simple types are copied by value, so there could be copies created instead of references.", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2014-06-03T19:39:57.000+0000", "updated": "2014-06-03T19:39:57.000+0000" }, { "id": "307387", "author": { "name": "matthewcongrove", "key": "matthewcongrove", "displayName": "Matthew Congrove", "active": true, "timeZone": "America/Chicago" }, "body": "1. The use-case here is for when someone is creating a custom navigation stack to control windows. In this situation, they are simply pushing a pointer to the controller to a stack array, and later on they may want to determine what params were passed to instantiate one of those controllers. This means that, unless they also store the name/params in an array, the values are lost as they were temporary variables.\r\n\r\n2. Agree, it could cause confusion. The idea is that they would not be able to be changed, but instead are just a way to reference what was initially used. Just like the __controllerPath property currently used by Alloy (internally).\r\n\r\n3. As I mentioned in #1, the use-case is that the parameters were stored as temporary, local vars. Could someone do it wrong and run into this issue? Probably.\r\n\r\nI admittedly haven't thought through all of the different possible use-cases, I was just filing a request for a specific use-case my client is running into and seeing if you guys had any thoughts on the matter. There are workarounds which are quite simple (e.g. exporting the values from the controller), but that's something they'd have to remember to add to every controller... figured it may be worth just building it in. If there are too many downsides, though, we can close this.", "updateAuthor": { "name": "matthewcongrove", "key": "matthewcongrove", "displayName": "Matthew Congrove", "active": true, "timeZone": "America/Chicago" }, "created": "2014-06-03T19:51:03.000+0000", "updated": "2014-06-03T19:51:03.000+0000" }, { "id": "327001", "author": { "name": "ppritchard", "key": "ppritchard", "displayName": "Peter Eddy Pritchard", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I suggest invoking function in BaseController module ... the generated code already passes the args to the BaseController module ... I just added named args in Constructor function:\r\n\r\nvar Controller = function(inArgs) {\r\n\r\nand then invoke a second function at the end of the constructor function itself:\r\n\r\n\tvar initReturn = this.init(inArgs);\r\n\r\n(ignore the return value ... I return a deferred to trigger a custom render() when remote objects are available)\r\n\r\nAs long as you pass those args to a subclass hook function (like initialize or beforeRender), then there is no need to \"record\" the value as an object property. Developers need only override the function to get at the value.", "updateAuthor": { "name": "ppritchard", "key": "ppritchard", "displayName": "Peter Eddy Pritchard", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-10-05T04:31:13.000+0000", "updated": "2014-10-05T04:31:13.000+0000" }, { "id": "327056", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "(Not truly a duplicate, but I don't see a better Resolution option to choose.)", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2014-10-06T19:51:34.000+0000", "updated": "2014-10-06T19:51:34.000+0000" }, { "id": "327057", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "This is going to be resolved by the ALOY-1092 change. Though, the controller path was already available as child.__controllerPath. The change I made will also make the args available. \r\n\r\n{code}\r\nvar child = Alloy.createController('childWindow', { someProperty: true});\r\n// worked previously\r\nconsole.log(\"__controllerPath = \" + child.__controllerPath);\r\n// will work with the ALOY-1092 PR\r\nconsole.log(\"args = \" + JSON.stringify(child.args));\r\n{code}", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2014-10-06T19:51:50.000+0000", "updated": "2014-10-06T19:51:50.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }