documentcloud/backbone — Issue #888: Removal of "_add" and "_remove"
Author: PaulUithol
Created: 2012-01-24 16:56:19+00:00
State: open

I'd like to discuss the removal of `Collection._add` and `Collection._remove`. I realize these methods were not part of the "public" API of course, but they were quite useful nonetheless.

These methods exposed functionality that is not otherwise available in Backbone, and were therefore very useful as hook points for extensions (not least of all for me in Backbone-relational). Both of these took a single snippet of data (either a model, or an object that might contain an `id` somewhere... or not) and return the model operated upon. Since both `add` and `remove` simply return the complete collection, they can not be used to determine this, especially when passing in JSON.

I have a sort-of-working workaround for Backbone-relational (using `_.clone(this.models)` before adding, then calling `add`, using `_.difference( this.models, clone )` afterwards and iterating over the diff), but this is quite a performance penalty when compared to the current situation. Especially considering many people use relational exactly because it automates the handling of a very large amount of models, and this whole process is repeated for every single addition.

Any chance these two could be re-instated?