scttnlsn / backbone.io

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

Emit vs Broadcast #19

Closed samhatoum closed 12 years ago

samhatoum commented 12 years ago

Hello

I previously used socket.io and backbone and was using broadcast, but now that emit is being used, I've had to put filters on the front end to see if the event originated from "this client" to omit sync backs (I'm doing live dom manipulation and double events cause a "bounce").

Is it possible to tell backbone.io to fire off a broadcast instead of a emit? I've looked at the source and can't see an obvious way to do it.

Thanks

Sam

scttnlsn commented 12 years ago

Hmm. It should be broadcasting: https://github.com/scttnlsn/backbone.io/blob/master/lib/index.js#L52 Maybe Socket.IO has changed the way this works. I will need to investigate this a bit. Do you have a specific example you could share that demonstrates the problem?

samhatoum commented 12 years ago

Hello

Seems this is a user error :) In trying to provide an example, I created a simple screen with CRUD buttons and which spits out logs on 'all' events. As a result, I can see it's a broadcast and not an emit, which means in my code I must be listening to the wrong events. I should be listening to backend:updates and not adds.

If you'd like, I can send you this SyncTest code as it may be useful for others to learn from