-
Notifications
You must be signed in to change notification settings - Fork 7.3k
newListener event #8853
Comments
This is either a bug in the EE or in the docs. |
Well, to be fair, the docs say that the behavior is "unspecified" if the listener is already added. It does not actually say that the event won't be fired multiple times. Still, this behavior feels a bit wonky and ought to be looked at. |
nodejs#8853 ... specifically, acknowledge in the docs that EE.addListener(...) does not check to see if the given listener has already been added, and that newListener will be called regardless of whether an already existing listener is added twice.
You misread the admittedly poorly worded docs: https://github.com/joyent/node/pull/8883/files#r21945241 |
Hmm.. hard to misread something so poorly written in the first place ;-). To be certain, the docs say nothing about the listener being added multiple times. I'll admit, it tends towards a "doctor, it hurts when I do this" kind of situation, but the docs are obviously lacking here. |
Per nodejs#8853, improvements to documentation for addListener, removeListener and newListener to reflect the fact that addListener allows any single listener to be added multiple times (which is silly, but needs to documented)
Improvements to events.markdown documentation per nodejs#8853 (same fix as before but rebased on joyent/v0.10
Clarify that adding or removing a listener is not idempotent. RE: nodejs#8853 PR: nodejs#8911 PR-URL: nodejs#8911 Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
Clarify that adding or removing a listener is not idempotent. RE: nodejs#8853 PR: nodejs#8911 PR-URL: nodejs#8911 Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
Resolved in the io.js docs. Will pick up the change from there in the converged repo |
In http://nodejs.org/api/events.html is written:
From this snippet I learnt that if listener is in listeners the
newListener
event is not fired.I did
event
newListener
is fired twice in spite of fact that listener is just in listeners array.May be I am wrong.
The text was updated successfully, but these errors were encountered: