37:46f343bd26af default tip
Anton Shestakov <av6@dwimlabs.net>, Thu, 05 Jul 2018 22:55:53 +0800
demo: jQuery 3.3.1

previous change 26:4e7999b5675c

README.md

Permissions: -rw-r--r--

Other formats: Feeds:
Overview
========
Backbone.Shard is a variation on a Subset taken from different perspective.
Shard was built as a simple "persistent filter" for collections; it can help
grouping and displaying items of a certain kind based on your filter function.
Usage
=====
Shard shares with Backbone.Collection most of the methods listed in
**Underscore methods** section of the
[Backbone documentation](http://backbonejs.org/#Collection-Underscore-Methods):
:::javascript
var shelf = Backbone.Shard({
collection: books,
filter: function(book) { return book.get('read'); }
});
shelf.each(...);
shelf.pluck(...);
You can add/remove models or reset *the original collection* and Shard will
honestly try to keep up with it, but currently Shard itself has no methods such
as add/remove/reset.
Events work and respect your filter function:
:::javascript
shelf.on('add', doSomething);
collection.add({read: true}); // this will call doSomething
collection.add({read: false}); // this won't
Tests
=====
Tests can be run [here](https://demos.dwimlabs.net/backbone-shard/test/) or you
can download the
[source](https://bitbucket.org/av6/backbone-shard/get/tip.tar.bz2) and open
test/index.html in your browser.