scttnlsn / backbone.io

Backbone.js sync via Socket.IO
http://scttnlsn.github.io/backbone.io
541 stars 66 forks source link

Multiple backends #50

Closed geekyme closed 11 years ago

geekyme commented 11 years ago

Hello,

Thank you for this awesome project @scttnlsn

I noticed the examples only include a single backend to sync one type of collection. What if I have 2 different types of collections to sync? Example: Backbone collection A: Messages Backbone collection B: Users

How do I make it work?

scttnlsn commented 11 years ago

On the server side, instantiate multiple backends:

var messages = backboneio.createBackend();
var users = backboneio.createBackend();

backboneio.listen(server, { messages: messages, users: users });

And on the client you can specify the backend with which a collection will sync:

var Messages = Backbone.Collection.extend({ backend: 'messages', ... });
var Users = Backbone.Collection.extend({ backend: 'users', ... });
geekyme commented 11 years ago

awesomeee thank you!!