Hi everyone,
I'd like to get people's comments on my proposal for a 'removedListener'
event https://github.com/joyent/node/issues/3243 as per issac's request.
Specifically: if the newListener and a proposed removedListener are
currently or would be used much, and what sort of need there is for such a
feature.
The general idea or use case behind having both of these events is to allow
complex libraries to not require extra processing required to gather data
that an event emits if there is no one listening. Although this can be
polled by checking the length of the listeners array, these events are
particularly useful when working with external systems that require other
listeners to be attached (and detached - currently cannot be done without
removedListener event), and also I'd think that storing a variable would be
quicker than checking the length constantly (not sure though, this is a
minor point compared with the other one, or at least provides
greater flexibility for developers).
It's also come up that the currently existing newListener feature isn't
bug-proof as it is not called if a user manually edits the listener array
with push,pop,etc. but I'm also interested to as which people use much, and
would there ever expected to be a modification of that array still
triggering these events, or simply leave it as an exception to the rule.
I personally didn't want to bring it up just for the current support to be
removed, but perhaps that is acceptable if there is a better way to do my
use case (and any other use case that are currently supported by the
existing 'newListener').
Thanks everyone.