documentcloud/backbone — pull request #1856 by caseywebdev (2012-12-01 00:01:00+00:00)
Title: Add Collection#update to better use collection events

Here's the use case. I have a collection of users that varies in size and attributes over time. I want to periodically poll the server and receive updates so I can render my views accordingly. With the current `reset`, I can wipe my view clean and re-render pretty easily, but I can't reuse my existing DOM (easily with events).

With `update`, I can poll my server and listen for `add`/`change`/`remove` on the collection. This is much nicer as now I have the power to do specific tasks on these events rather than some bulk task on `reset`.

Regarding `fetch`, `Model#fetch` doesn't set `attributes` to `{}` and then fill them with the response, and `Collection#fetch` shouldn't do that for its models (by that I mean completely emptying the set and refilling). This patch is non-breaking, `update` can be used instead of `reset` by passing `{update: true}`. However, I really think the default action for `Collection#fetch` should be `update`, and a new major/minor version would be the time to introduce it.