Arrays that automatically update your UI.
$ component install tower/collection
var collection = require('tower-collection');
Create a blank collection:
collection(); // []
collection([]); // []
collection.push(item);
collection.push(item1, item2);
collection.pop();
Remove first item in array.
collection.shift();
Add item(s) to beginning of array.
collection.unshift(item);
collection.unshift(item1, item2);
Modify the original array.
collection.splice(1, 2, item);
collection.length;
The collection
is only necessary to bind lists of data (such as queries) to the DOM. It just makes it easier to listen for changes to an array. In most other cases you can just use plain arrays and don't need the power of dirty tracking.
MIT