{ "id": "117169", "key": "ALOY-747", "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": [ { "id": "15571", "description": "2013 Sprint 15", "name": "2013 Sprint 15", "archived": true, "released": true, "releaseDate": "2013-07-29" } ], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2013-07-17T20:57:33.000+0000", "created": "2013-07-15T06:13:40.000+0000", "priority": null, "labels": [ "alloy", "compare", "views" ], "versions": [], "issuelinks": [], "assignee": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2013-07-22T17:58:42.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "12326", "name": "XML", "description": "View XML and parsing" } ], "description": "This issue builds forth on TC-2609, asking for dynamic namespace loading for Alloy view components.\r\n\r\nIf using existing object factories, being either native or CommonJS modules, these might not always follow the convention of {{createTagName}}, {{add}} and {{remove}} for creating the view component, adding a child to it or removing it.\r\n\r\nUsing optional {{toCreate}}, {{toAdd}}, {{toRemove}} attributes, one should be able to override these defaults, so that:\r\n\r\n{code}\r\n\r\n \r\n \r\n \r\n\r\n{code}\r\n\r\nproperly translates into:\r\n\r\n{code}\r\nif (typeof MyFactory === 'undefined') var MyFactory = require('my.factory');\r\n$.__views.__alloyId1 = MyFactory.get({ .. });\r\n$.__views.__alloyId2 = Ti.UI.createLabel({ text: 'Some label, .. });\r\n$.__views.__alloyId1.attach($.__views.__alloyId2);\r\n{code}", "attachment": [], "flagged": false, "summary": "Alloy: Add attributes to override create, add and remove methods", "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": "Any", "comment": { "comments": [ { "id": "261748", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Here is the PR: https://github.com/appcelerator/alloy/pull/179", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2013-07-15T06:30:56.000+0000", "updated": "2013-07-15T06:30:56.000+0000" }, { "id": "261788", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Why would I do this as opposed to just creating a separate controller/view and referencing it with ? This seems like a lot of cruft in the XML attributes to do something that is essentially already solved with self-contained controllers. I would prefer to focus on resolving the issue that XML elements can't be nested inside or attributes. Would that work just as well for you?", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-15T13:41:39.000+0000", "updated": "2013-07-15T13:41:39.000+0000" }, { "id": "261791", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Well, I can think of two reasons:\n\n* Using {{ns}} like discussed in ALOY-743 the view could come from a native module as well.\n* This could be a good way to include legacy code in a app rewritten (partially) in Alloy.", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2013-07-15T13:48:41.000+0000", "updated": "2013-07-15T13:48:41.000+0000" }, { "id": "261801", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "But would the ability to nest elements in make this easier? It wouldn't cover handling legacy code, but that's not a primary concern of mine. My main issue is that I feel that Alloy has almost too many special XML attributes as it stands, I'm very hesitant to add anymore because it will be (near) impossible to remove them if and when we do find a cleaner way to implement this. It just feels a little to shoe-horned in when can do the bulk of this already.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-15T14:30:54.000+0000", "updated": "2013-07-15T14:30:54.000+0000" }, { "id": "261852", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "I just discovered another, more crucial one :) By default, in {{compilerUtils.js}} on line 253, Alloy uses {{.addEventListener}} for {{Ti.}} namespaces and {{.on}} for all others when using the {{onEvent}} attribute in views. If I have my own factory wrapping Titanium proxy objects, this won't work.\n\nSo I guess I would like to add a 4th: {{toBind}} ;)", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2013-07-15T19:19:09.000+0000", "updated": "2013-07-15T19:19:09.000+0000" }, { "id": "261854", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "As I think you are realizing, it's feeling far to \"bolted on\" to go through at this point. There's just too many little things to consider and I don't want to add an XML attribute every time we find another one.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-15T19:23:59.000+0000", "updated": "2013-07-15T19:23:59.000+0000" }, { "id": "261973", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "What about instead introducing one new element to register new namespace objects? That would be similar to registering namespaces in HTML and more clear because you're aware of what you're doing.\n\n{code}\n\n \n \n\n{code}\n\nThis element should be used to inform Alloy on a namespace's behavior (create/add/remove) as well as optionally specifying a CommonJS/native module to require (if not already in global scope).", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2013-07-16T05:10:57.000+0000", "updated": "2013-07-16T05:10:57.000+0000" }, { "id": "262166", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-17T16:13:36.000+0000", "updated": "2013-07-17T16:13:36.000+0000" }, { "id": "262228", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "In short, I like the ability to allow arbitrary UI components to be inserted via XML, but I don't want this crazy level of flexibility managed in XML. New UI components should abide by the standard interface for creating components and adding/removing them from the view hierarchy.\n\n{code:xml}\n\n{code}\n\nis expected to implement my.stuff.createSomeComponent(), my.stuff.SomeComponent.add(), my.stuff.SomeComponent.remove(), and any other Titanium-like function that it may make use of. We should more clearly define this interface, but allowing an arbitrary interface is deviating too far from creating a coding standard, which is what Alloy is aiming to do.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-17T20:53:50.000+0000", "updated": "2013-07-17T20:53:50.000+0000" }, { "id": "262229", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing this as based on our conversation I don't think this method or the associated PR best suits Alloy goal of establishing a clear coding standard. I'll be happy to continue the conversation, but I think cleaner long-term solutions have been put forth.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-17T20:57:33.000+0000", "updated": "2013-07-17T20:57:33.000+0000" }, { "id": "262288", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "I can live with this decision ;)\r\n\r\nWriting a custom parser would be too complicated and time consuming for most I think, but I agree that asking of modules to follow the create, add, remove and even 'on' convention is not too much asked.\r\n\r\nThen the only issue left is a more clean loading of the module, but we'll discuss that further in ALOY-743.", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2013-07-18T06:19:23.000+0000", "updated": "2013-07-18T06:19:23.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }