Flotype / now

NowJS makes it easy to build real-time web apps using JavaScript
http://www.nowjs.com
MIT License
1.91k stars 175 forks source link

Calling .on multiple times on a ClientGroup creates multiple event triggers. #68

Closed aashay closed 13 years ago

aashay commented 13 years ago

See this gist for more detail (including a test script and console output): https://gist.github.com/939974

Basically, it seems like if I do something like this: var group = nowjs.getGroup("FOO"); group.on('connect', function(){ ... });

and I call it multiple times (i.e if it's in a function that gets called by multiple clients), the .on method should be idempotent. It isn't. I'm not sure if this is the desired output but if it is, it should probably be doc'd, because it's a little confusing as-is.

sridatta commented 13 years ago

This is expected behavior for the EventEmitter objects, as documented by http://nodejs.org/docs/v0.4.6/api/events.html#emitter.on . The .on method is not idempotent; it appends a new listener every time it is called.

aashay commented 13 years ago

Ah ok, thanks for the clarification. Might be useful to doc that for us noobs! :)

ericz commented 13 years ago

Thanks for issue Aashay, I'll put this into the documentation so it's clear.

Eric