Skip to content

Instantly share code, notes, and snippets.

@devinhunt
Created August 2, 2011 12:03
Show Gist options
  • Save devinhunt/1120063 to your computer and use it in GitHub Desktop.
Save devinhunt/1120063 to your computer and use it in GitHub Desktop.
Faye and collections
window.ArtistCollection = Backbone.Collection.extend({
initialize: function(models, ops) {
if(ops.updater) {
this.updater = ops.updates;
this.updater.bind('update', _.bind(this.onUpdater, this));
}
},
onUpdater: function(response) {
// send the updates to the correct model
// id. Maybe even as a parse args if its
// in full model json
}
});
// then just
var popArtists = new ArtistCollection(null, {updater: window.fayeClient});
var trackedArtists = new ArtistCollection(null, {updater: window.fayeClient});
// if this is a common pattern, you could wrap it into a new Backbone base
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment