masylum/Backbone.Subset — pull request #1 by latentflip (2012-01-25 11:13:10+00:00)
Title: Liveupdating subsets

Hi guys.

I found subset last night, and it's looking pretty awesome. For my use however, I wanted subsets to be automatically updated if a model's attributes change. i.e:

```
tasks.reset([{archived: true}, {archived: false}]);

assert.equal(tasks.length, 2);
assert.equal(archivedTasks.length, 1);

tasks.first().set({archived: false});
assert.equal(tasks.length, 2);
assert.equal(archivedTasks.length, 0);
```

This makes it really easy to keep my views in sync with any changes made to models by the user/app. So here's a patch that does just that.

I've added a `liveupdate_keys` attribute to the subset. If set to `'all'`, the subsets will be updated on all model changes. If set to an array of attributes (`liveupdate_keys = ['archived']`), the subset will only be updated when those keys change. If set to `'none'` or `''` the subset will not be live updated.

### Before merging, I'd love some discussion/feedback on:

* is this a good idea?
* should liveupdating be the default behaviour (currently `liveupdate_keys` defaults to `'all'` in my branch).
* is `liveupdate_keys` an appropriate name for the property

Thanks!
Phil