scttnlsn / backbone.io

Backbone.js sync via Socket.IO

Home Page:http://scttnlsn.github.io/backbone.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Emit vs Broadcast

samhatoum opened this issue · comments

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

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?

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