: Stop using AppStorage directly. It’s prone to typos, value mismatches and more.

Instead give yourself strongly typed keys and associated defaults, à la EnvironmentValues.

I’ve published my implementation as a package, but you can just as easily wrap AppStorage yourself with a few dozen lines.

github.com/notsobigcompany/Big

@phill I’m doing almost the same by introducing a „TypedKey“, but added a buch of initializers to AppStorage. Upside: It’s as familiar as possible to anyone who knows AppStorage.

TypedKey is also used everywhere where having typed values and potentially default values makes sense. I strongly wonder why it’s not part of the system tbh.

Follow

@gernot very cool and similar! Great minds :-)

And yes it’s curious AppStorage works the way it does when the EnvironmentValues system is sat right there.

Sign in to participate in the conversation
The Not So Big Company

The home of The Not So Big Company on Mastodon.