{ "id": "106730", "key": "ALOY-431", "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": "2012-12-18T18:01:10.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-03-07T22:26:05.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": [ { "id": "13605", "name": "Models" }, { "id": "12329", "name": "Runtime", "description": "Generic bucket for uncategorized runtime issues" } ], "description": "Developers right now technically have access to the class definitions of models and collections. If a developer had a model/collection named \"items\", they could access the class definition like this:\r\n\r\n{code:javascript}\r\nvar ModelClass = require('alloy/models/Items').Model;\r\nvar CollectionClass = require('alloy/models/Items').Collection;\r\n\r\n// you can access class properties and functions\r\nCollectionClass.someFunctionOnTheCollectionClass();\r\n\r\n// you can then use Backbone inheritance \r\nvar DerivedModelClass = ModelClass.extend({\r\n // properties and functions to add to the class\r\n});\r\n\r\n// and then create an instance\r\nvar instance = new DerivedModelClass({ /* init object */ });\r\n{code}\r\n\r\nNotice that the initial require() needs the model name to have its first letter capitalized. We should introduce a simpler syntax for accessing the class itself. Some ideas:\r\n\r\n* - *Alloy.Models.Items* (might be confusing with the corresponding global instance being created at Alloy.Model.items)\r\n* - *Alloy.getModel('items')* (take the old deprecated function and have it return the class instead of an instance)", "attachment": [], "flagged": false, "summary": "Expose Model and Collection class definitions more easily", "creator": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [], "maxResults": 0, "total": 0, "startAt": 0 } } }