[ALOY-403] Create Alloy.Collections.instance() and Alloy.Models.instance() functions
| GitHub Issue | n/a |
|---|---|
| Type | Story |
| Priority | High |
| Status | Resolved |
| Resolution | Fixed |
| Resolution Date | 2012-11-29T23:20:43.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Alloy 0.3.3, 2012 Sprint 24 |
| Components | Runtime |
| Labels | n/a |
| Reporter | Tony Lukasavage |
| Assignee | Unknown |
| Created | 2012-11-29T22:31:11.000+0000 |
| Updated | 2018-03-07T22:26:09.000+0000 |
Description
Right now the generated code for making sure we have an instance of a singleton Collection (or Model) looks like this:
or is used in markup. This will help reduce the size of the code, and make it more readable.
Alloy.Collections.todo || (Alloy.Collections.todo = Alloy.createCollection("todo"));
It would be nicer to have a function that returns an instance if we need one, or the already created instance if it exists. Basically, the line of code above shouldn't be generated every single time a
Alloy.Collections.instance('todo');
Alloy.Models.instance('todo');
No comments