can.Model.List
inherits: can.Observe.List
Works exactly like can.Observe.List and has all of the same properties, events, and functions as an observable list. The only difference is that when an item from the list is destroyed, it will automatically get removed from the list.
Creating a new Model List
To create a new model list, just use
new {model_name}.List(ARRAY)
like:Model Lists in
can.Model
can.Model.findAll or models will almost always be used to return a
can.Model.List
object, even though it is possible to create new lists like below:Extending
can.Model.List
Creating custom
can.Model.Lists
allows you to extend lists with helper functions for a list of a specific type. So, if you wanted to be able to see how many todos were completed and remaining something could be written like:Removing models from model list
The advantage that
can.Model.List
has over a traditionalcan.Observe.List
is that when you destroy a model, if it is in that list, it will automatically be removed from the list.