Skip to content

Instantly share code, notes, and snippets.

@vkovalskiy
vkovalskiy / LiveCollection.js
Created March 1, 2012 08:02 — forked from gordonbrander/LiveCollection.js
Backbone Live Collections w/ Streaming and Automatic Duplicate Handling
var LiveCollection = (function (_, Backbone) {
var Collection = Backbone.Collection;
// Define a Backbone Collection handling the details of running a "live"
// collection. Live collections are expected to handle fetching their own
// data, rather than being composed from separate models.
// They typically add new models instead of resetting the collection.
// A custom add comparison makes sure that duplicate models are not
// added. End result: only new elements will be added, instead
// of redrawing the whole collection.
//