-
Notifications
You must be signed in to change notification settings - Fork 57
Add support for string arrays to AppStorageKey
#107
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
Conversation
@ph1ps We've resisted expanding the surface area here to keep things in line with Apple's We're open to revisiting this, but would want to do so in a holistic manner that also considers support for |
Thanks for the great library! I've noticed that @shared(.fileStorage) already supports Codable through optional encoder and decoder parameters. However, @shared(.appStorage) doesn't currently support Codable types in a similar way, despite having a very similar API design. Could you share the reasoning behind why fileStorage supports custom encoder and decoder, but appStorage does not? Would it make sense to align appStorage with the existing fileStorage design to provide consistent support for Codable types? |
Currently, I'm forced into a quite unfortunate workaround:
It would be great if @shared(.appStorage) could follow the same pattern as fileStorage, allowing for clean and direct Codable support, thus avoiding such painful boilerplate. |
I think this should be moved to a discussion, rather than commenting on this MR. |
We've merged #182 and believe it's worth shipping this overload as an optimization. Thanks! |
Co-authored-by: Stephen Celis <[email protected]>
Kind of a weird exception, but
UserDefaults
supports[String]
natively, so I'd suggest to also add support toAppStorageKey
. Theoretically, users could create their own workarounds here, by just serializing/deserializing the array and usingData
as an intermediate, so this addition might not be necessary.Alternatively, I could take a look to support arrays in general: https://developer.apple.com/documentation/foundation/userdefaults/1414792-array. However, this might add a lot of overloads.
What do you think?