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.Modelcan.Model.findAll or models will almost always be used to return a
can.Model.Listobject, even though it is possible to create new lists like below:Extending
can.Model.ListCreating custom
can.Model.Listsallows 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.Listhas over a traditionalcan.Observe.Listis that when you destroy a model, if it is in that list, it will automatically be removed from the list.