Backbone.js collection filtering
plus.google.com
plus.google.com
var mycollection = new MyCollection();
...
mycollection.each(function(model) {
model.set({'passesFilterXYZ': filterXYZ(model)});
});
EDIT: it also makes an entirely new collection instance representing the set of filtered models...this seems terribly inefficient compared to the above.Maybe I am citing the wrong pattern here. Basically each collection "filter" will do it's own work and pretend like it in itselfis a collection. The pagination is like a collection, but filtered in some way, the filtering is too. Eventually I can easily implement another in the chain to fetch records when I page to the page containing the record (say the record really only contains the ID) and it would be pretty trivial to do.
Also lets you have a master collection of data, and multiple views doing different things with that master collection, without constantly changing the master.