-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
Custom storage #18
Comments
I would love this! |
@sindresorhus I took a stab at this here fredlb#1 An implementation example of
I would love some feedback on this, and I'll file a proper PR if we want to go down this route :) |
The problem with a solution like this (that I did not think of when initially proposing it) is that in an app you may want to both use the default storage, but also have a custom storage for some shortcuts. That's actually the case for one of my apps. I have a global keyboard shortcut for toggling the app (using the default storage), but also keyboard shortcuts per item (custom storage). |
I wonder if it would be simpler and more flexible to make |
The defaults here are great and will work for most, but some users will need to store the keyboard shortcuts differently. For example, they are migrating from a different keyboard shortcut solution or they have a different preferred way of storing the shortcuts. I think we could expose a few storage-related hooks that would solve a lot of use-cases in one go.
We could add a protocol with a few required methods:
get
set
contains
remove
The default implementation of this protocol would be the current UserDefaults storage, but a user could override it like this
KeyboardShortcuts.storage = myStorage
if needed.Thoughts? Am I over-designing this?
The text was updated successfully, but these errors were encountered: