Titanium JIRA Archive
Alloy (ALOY)

[ALOY-379] Create <Collection> in markup (instance)

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusResolved
ResolutionFixed
Resolution Date2012-11-28T22:02:04.000+0000
Affected Version/sn/a
Fix Version/sAlloy 0.3.3, 2012 Sprint 24
ComponentsRuntime, XML
Labelsnotable
ReporterTony Lukasavage
AssigneeUnknown
Created2012-11-13T17:19:39.000+0000
Updated2018-03-07T22:25:47.000+0000

Description

The tag currently only creates/references a global singleton version of the collection. We need to implement such that instances bound to the current controller can be created as well.

Proposed Syntax

*NOTE:* must always be the child of

Singleton

<!-- "src" is the Alloy Model on which the collection is based -->
<Alloy>
    <!-- Accessible globally as Alloy.Collections.myModel -->
    <Collection src="myModel"/>
</Alloy>

Instance

<!-- * "src" is the Alloy Model on which the collection is based 
     * "id" works just like it does on UI components, creating a reference
     * "instance" tells Alloy to create an instance instead of a singleton -->
<Alloy>
    <!-- Accessible as $.myModel in corresponding controller -->
    <Collection id="someId" src="myModel" instance="true"/>
</Alloy>
While a singleton would be made available in Alloy.Collections, an instance collection will be attached to the current controller just as a UI component. So the above instance collection would be accessible in controller code like this:
var collectionInstance = $.someId;

Comments

  1. Tony Lukasavage 2012-11-28

    In the process of creating instances, a lot of additional validation and error reporting was added to the Alloy.Collection parser. In addition, the models/todo_binding test app was updated and had a bug or two in it fixed.

JSON Source