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

Feature Request: unbind scope #166

Open
caillou opened this issue Dec 14, 2016 · 1 comment
Open

Feature Request: unbind scope #166

caillou opened this issue Dec 14, 2016 · 1 comment

Comments

@caillou
Copy link

caillou commented Dec 14, 2016

Feature Request: Unbind Scope

Motivaiton

I often find myself writing the following code:

['up', 'down', 'esc'].forEach((key) => {
  keymaster.unbind(this.scope, key)
})

While this works, it could potentially lead to memory leaks, if a specific key is forgotten. E.g. if my module would have registered key('space', this.scope, cb).

Proposed Solution

A possibility to remove every event-handler for a given scope would be very helpful. Possible APIs:

keymaster.unbind(null, this.scope)
keymaster.unbindScope(this.scope)

Discussion

If such a feature is desired, I would be willing to send a PR along with tests. This being said, I would love to get your input on this beforehand. Do you consider the use-case good enough to add this functionality to keymaster? And if yes, what would the ideal API for this be?

@tbleckert
Copy link

If you are already using scopes, can't you just do: key.deleteScope(this.scope);

According to the docs deleteScope removes all events that are in that scope

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

2 participants