You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
This is different from a lot of other libraries (jQuery) and removeEventListener in the DOM where the same listener can be added multiple times, and removal removes all handlers for for the same event/listener combo.
It seems like the only way to determine if all events of the same type/handler are removed, is to listen for removeListener and keep calling removeListener until it's no longer emitted, or to manually iterate through the listener array checking for listener.
Example of issue:
functionfoo(){}process.on('foo',foo)process.on('foo',foo)process.emit('foo')// foo called twiceprocess.removeListener('foo',foo)process.emit('foo')// foo still called
Is this by design? It would cause memory leaks if someone was not familiar with this issue and was extending and creating a a long lasting EventEmitter.
The text was updated successfully, but these errors were encountered:
Maybe not originally but it's pretty much codified now. I don't want to change the behavior either; EventEmitter#removeListener() gets called a lot and is already quite expensive. Doing mandatory full scans over the listeners array would make that a lot worse.
The event subsystem is locked at this point. I'd be willing to accept refactoring changes to improve performance, but any interface changes should be considered final as of 0.10.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This is different from a lot of other libraries (jQuery) and removeEventListener in the DOM where the same listener can be added multiple times, and removal removes all handlers for for the same event/listener combo.
It seems like the only way to determine if all events of the same type/handler are removed, is to listen for
removeListener
and keep calling removeListener until it's no longer emitted, or to manually iterate through the listener array checking for listener.Example of issue:
Is this by design? It would cause memory leaks if someone was not familiar with this issue and was extending and creating a a long lasting EventEmitter.
The text was updated successfully, but these errors were encountered: