Closed aashay closed 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.
Ah ok, thanks for the clarification. Might be useful to doc that for us noobs! :)
Thanks for issue Aashay, I'll put this into the documentation so it's clear.
Eric
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.