jashkenas/backbone — pull request #2816 by jdudek (2013-10-16 16:09:46+00:00)
Title: Add `set` event triggered once when collection models are added or removed

Events `add` and `remove` are a great way to keep a view in sync with collection. A view can observe when collection's content changes and re-render itself. A model can be added only in the client or loaded from the server and this is transparent to the view.

However, `add` and `remove` are triggered for every single model added/removed, which results in render being called multiple times. This causes performance issues, as rendering can be a heavy operation.

I'm not the first one to encounter this problem:
* http://backbonefu.com/2013/08/handling-multiple-collection-add-models-in-a-batch/
* http://blog.pamelafox.org/2013/06/improving-backbone-app-performance.html

My suggestion is to add a new event `set` that is triggered every time models are added or removed, but just once during one operation. E.g. calling `add` with multiple models will trigger `add` event for every model and `set` event only once.