{ "id": "98385", "key": "ALOY-150", "fields": { "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [ { "id": "14081", "description": "", "name": "2012 Sprint 16", "archived": true, "released": false }, { "id": "14176", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": false, "released": true, "releaseDate": "2012-12-13" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-08-13T09:50:22.000+0000", "created": "2012-07-30T23:46:28.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [], "versions": [ { "id": "14081", "description": "", "name": "2012 Sprint 16", "archived": true, "released": false } ], "issuelinks": [], "assignee": null, "updated": "2018-03-07T22:25:58.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" }, { "id": "12326", "name": "XML", "description": "View XML and parsing" } ], "description": "I think this means we can get rid of the $. syntax completely.", "attachment": [], "flagged": false, "summary": "Change the current hidden exports to be explicit just as in regular commonjs", "creator": { "name": "rmcmahon", "key": "rmcmahon", "displayName": "Russell McMahon", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "rmcmahon", "key": "rmcmahon", "displayName": "Russell McMahon", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "210836", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I'd like to go beyond just renaming {{$}} to {{exports}} and do some restructuring based on feedback from the google groups (Rick). Specifically, I'd like to support controller inheritance. Since we are already using Backbone and it has a very simple inheritance format for Models and Collections, I'm proposing we do the same with Alloy's controllers.\r\n\r\nbackbone does this:\r\n\r\n{code:javascript}\r\nvar MyModel = Backbone.Model.extend({});\r\nvar instance = new MyModel();\r\n{code}\r\n\r\nperhaps we should follow suit:\r\n\r\n{code:javascript}\r\n// make the getController return a controller definition instead of\r\n// an instance of a controller.\r\nvar MyController = Alloy.getController('myController');\r\n\r\n// we could then use an extend function, just like Backbone, to allow\r\n// a new derivative controller to inherit from another.\r\nvar MyDerivativeController = MyController.extend({\r\n customProperty: 1,\r\n customFunction: function() {}\r\n});\r\n\r\n// use new to create an instance\r\nvar controller = new MyDerivativeController();\r\n\r\n// Or if you prefer a single assignment\r\nvar controller = new Alloy.getController('myController').extend({\r\n customProperty: 1,\r\n customFunction: function() {}\r\n});\r\n{code}\r\n\r\nfor reference, the above code would look like the below code now, and would not cleanly support controller inheritance:\r\n\r\n{code:javascript}\r\nvar controller = Alloy.getController('myController').create({});\r\n{code}", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-31T14:21:43.000+0000", "updated": "2012-07-31T14:28:19.000+0000" }, { "id": "210917", "author": { "name": "rmcmahon", "key": "rmcmahon", "displayName": "Russell McMahon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I like it. I think Backbone's method of extending the base is good. It allows both instance and class but maybe class is not needed now. But for reference:\r\n\r\nvar Model = Backbone.Model.extend(extendObj, extendClass); \r\n\r\n...\r\n\r\nmodel = new Model({});", "updateAuthor": { "name": "rmcmahon", "key": "rmcmahon", "displayName": "Russell McMahon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-31T19:55:22.000+0000", "updated": "2012-07-31T19:55:22.000+0000" }, { "id": "210973", "author": { "name": "rblalock", "key": "rblalock", "displayName": "Rick Blalock", "active": false, "timeZone": "America/Havana" }, "body": "I like this too. It's semi-close to how I code already in Ti apps. It's also similar to a lot of JS frameworks that do this as well (e.g. Mootools, JQuery). I also like the fact that I know I'm getting a new instance.", "updateAuthor": { "name": "rblalock", "key": "rblalock", "displayName": "Rick Blalock", "active": false, "timeZone": "America/Havana" }, "created": "2012-08-01T08:06:43.000+0000", "updated": "2012-08-01T08:06:43.000+0000" }, { "id": "211203", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The most relevant changes that removed unnecessary \"magic\", added the Backbone eventing and inheritance model, and provided much more extensibility to controllers:\r\n- new controller boilerplate: https://github.com/appcelerator/alloy/blob/master/Alloy/template/controller.js\r\n- new generated runtime controller template: https://github.com/appcelerator/alloy/blob/master/Alloy/template/component.js (devs won't see this)\r\n- BaseController.js: https://github.com/appcelerator/alloy/blob/master/Alloy/lib/alloy/controllers/BaseController.js (devs won't see this either)\r\n\r\nAll samples in [alloy/test/apps|https://github.com/appcelerator/alloy/tree/master/test/apps] have been updated to use the new controller syntax. Check there to see it in action.\r\n\r\nAlso, the [default generated index.js|https://github.com/appcelerator/alloy/blob/master/Alloy/template/default/index.js] for new projects has A LOT of inline documentation to get devs started until we have solid docs to reference. Anyone peeking in here, please let me know if they make sense, and if we need more or less description. Again, this will only be put into the default index.js controller when a new project is created. All other generated controllers will use the minimal boilerplate from the list above.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-02T09:27:24.000+0000", "updated": "2012-08-02T09:35:39.000+0000" }, { "id": "211252", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Things that need to be added:\r\n- life cycle events should be optional. Controller code can be defined without preLayout() and postLayout() \r\n- Add \"extends\" attribute to \\ tag for defining the parent controller (defaults to BaseController)\r\n- Add magic variable \"arguments\" to the lifecycle-less controllers", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-02T13:22:21.000+0000", "updated": "2012-08-02T13:22:21.000+0000" }, { "id": "211342", "author": { "name": "rmcmahon", "key": "rmcmahon", "displayName": "Russell McMahon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "1) Keep the preLayout and postLayout functionality as is. \r\n2) Make \"alloy new .\" just return controller with postLayout(args) {...} all the comments were good but better in docs.\r\n3) Remove $.parentController = Alloy.getController('BaseController'); from the controller generated from \"alloy generate controller\".\r\n\r\nFor extending the controller object (controller, style and view) open another ticket.\r\n\r\nThen let's close the ticket. We can review with team during sprint Demo.", "updateAuthor": { "name": "rmcmahon", "key": "rmcmahon", "displayName": "Russell McMahon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-02T20:01:51.000+0000", "updated": "2012-08-02T20:01:51.000+0000" }, { "id": "211405", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "OK, one more time around the bend on this one.\r\n\r\n* Flatten controller files. All code in the controller file is executed after the view hierarchy is established.\r\n** The lone exception to this rule will be the *optional* {{init()}} function. This function will not be part of the code executed ater the view hierarchy. It is instead executed when the controller class itself is created. \r\nThis function will return the base controller definition for this class. From here you can extend the base class definition, add lifecycle functions, or establish inheritance from a controller other than {{BaseComponent}}. Again, all optional. {code:javascript}function init() {\r\n return Alloy.getController('MySuperController').extend({\r\n customProperty: 123,\r\n customFunction: function(){},\r\n preLayout: function(args) { \r\n // execute code before view hierarchy is established \r\n }\r\n });\r\n}{code}\r\n* Markup events need to be reworked as private functions will no longer be available on the module and instead are wrapped up in a function for the base controller.\r\n* ", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-03T11:02:02.000+0000", "updated": "2012-08-03T11:10:03.000+0000" }, { "id": "211808", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "OK, once more, as per instruction\r\n\r\n* All commonjs module constructs will remain hidden. {{$}} is still used as a reference to the controller triad object.\r\n* Inheritance will be instance-based. This will no longer use the Backbone-like class-based extend() inheritance. {code:javascript}function Controller() {\r\n Alloy.getController('BaseController').call(this); // can eventually be set by markup\r\n var $ = this;\r\n\r\n // the rest of the view and controller code\r\n}\r\n{code}\r\n* A parent controller must be assigned in markup. We currently have no means to do so in the controller code itself. This means if you want a pure code controller as a subclass, you would still have to create an empty view file that looked like this: {code:xml}{code}\r\n* Controller code will be flattened. No special functions and/or syntax. All code in controllers ends up executed after the view hierarchy is created.\r\n* No lifecycle functions\r\n* The \"arguments\" variable is available in the controller, despite the fact that developers can't see the containing function. See also, \"magic\". ", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-06T07:33:07.000+0000", "updated": "2012-08-06T07:56:26.000+0000" }, { "id": "213102", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Now implementing the style shown in this gist:\r\n\r\nhttps://gist.github.com/3248559\r\n\r\nand the lifecycle events will look like this now:\r\n\r\nhttps://gist.github.com/3285234\r\n\r\nThis will be done in a new branch called *explicit_controller*. Both the current and this new method will be compared and evaluated to see which better suits the goals of Alloy.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-07T06:55:17.000+0000", "updated": "2012-08-07T09:32:22.000+0000" }, { "id": "213300", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "git branch \"ALOY-150\" created: https://github.com/appcelerator/alloy/tree/ALOY-150\r\n\r\nDevelopment on explicit controllers as listed in the previous comment will be done here.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-08T08:29:05.000+0000", "updated": "2012-08-08T08:29:05.000+0000" }, { "id": "213798", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "changes have been implemented in ALOY-150 branch of the repo. Will merge into master after the changes have been discussed.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-10T11:11:02.000+0000", "updated": "2012-08-10T11:11:02.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }