Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.off("name") removes all matching listeners #3

Open
kawanet opened this issue Feb 12, 2016 · 1 comment
Open

.off("name") removes all matching listeners #3

kawanet opened this issue Feb 12, 2016 · 1 comment

Comments

@kawanet
Copy link
Owner

kawanet commented Feb 12, 2016

EventEmitter#removeListener only removes 1 listener when an event name given:
https://nodejs.org/api/events.html#events_emitter_removelistener_event_listener

event-lite#off removes all. The undocumented behavior could be fixed.

See #1. @JoshuaWise would have a right code to fix this! ;)

@kawanet
Copy link
Owner Author

kawanet commented Feb 12, 2016

It seems jQuery's off("name") removes all matching listeners, by the way.

https://api.jquery.com/off/

If a simple event name such as "click" is provided, all events of that type (both direct and delegated) are removed from the elements in the jQuery set. When writing code that will be used as a plugin, or simply when working with a large code base, best practice is to attach and remove events using namespaces so that the code will not inadvertently remove event handlers attached by other code.

Adding a namespace is the best practice? I don't think that it's the best for event-lite to follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant