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

Custom storage for shortcuts #139

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fredlb
Copy link

@fredlb fredlb commented Jul 27, 2023

Related to #18, I've tried to implement a protocol to allow for custom storage implementations. It still defaults to using UserDefaults unless anything else has been specified before running KeyboardShortcuts.initialize().

You can consider this WIP, since it would probably be nice to add more tests etc, and documentation with examples how to use it.

This adds a protocol to allow for custom storage. It will default to UserDefaults unless anything else
has been specified prior to calling KeyboardShortcuts.initialize()
Copy link

@doriandevtech doriandevtech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments about additional comment and border effects covering

@@ -137,7 +138,11 @@ public enum KeyboardShortcuts {
guard !isInitialized else {
return
}


if storageProvider == nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest that a 'else' statement should be added to this 'if' just in case. This will help cover border effects.

@@ -277,29 +282,28 @@ public enum KeyboardShortcuts {
You would usually not need this as the user would be the one setting the shortcut in a settings user-interface, but it can be useful when, for example, migrating from a different keyboard shortcuts package.
*/
public static func setShortcut(_ shortcut: Shortcut?, for name: Name) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding comments about the parameters will help the understanding of this method.
This has been correctly done in 'Name.swift' 👍🏻

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

Successfully merging this pull request may close these issues.

None yet

2 participants