Created
August 2, 2011 12:03
-
-
Save devinhunt/1120063 to your computer and use it in GitHub Desktop.
Faye and collections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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