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

Way to unbindAll or destroy the instance? #49

Open
yuqianma opened this issue Jul 25, 2024 · 1 comment
Open

Way to unbindAll or destroy the instance? #49

yuqianma opened this issue Jul 25, 2024 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@yuqianma
Copy link

Is your feature request related to a problem? Please describe.

Got here from KeyboardJS. I'm looking for a keyboard lib for a new project.

There are some features in KeyboardJS looks awesome. Like setContext, watch, stop, which I cannot find in Keystrokes. (Am I missing something?)

However I feel an unbindAll method might be usefule enough as an alternative for these features. By which I can install/teardown easily like a context switch.

And it also benefits in libraries like react. Say we can orchestrate mutiple events to an instance in useEffect and destroy them once.

Describe the solution you'd like

Add unbindAll or even destroy?

How do you feel about this?

@RobertWHurst
Copy link
Owner

Indeed keystrokes leaves a bit more to the user. The idea was that your code already likely knows or has access to the context or state of your application, so one would just ignore calls to their handlers unless the context or state was correct.

As for unbinding, I figured usually that code would go with the original bind call. You can see this in the keystrokes react package here => https://github.com/RobertWHurst/Keystrokes/blob/master/packages/react-keystrokes/src/use-key-combo.ts#L14-L16

That all said, I do plan on improving the library as things progress, and it is good to know when people desire select improvements.

@RobertWHurst RobertWHurst added enhancement New feature or request question Further information is requested labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants