Document benefits over `@AppStorage`

This commit is contained in:
Sindre Sorhus 2022-01-23 13:43:12 +07:00
parent 5b30f01e46
commit a6c1c064fa
1 changed files with 12 additions and 1 deletions

View File

@ -21,6 +21,17 @@ For a real-world example, see the [Plash app](https://github.com/sindresorhus/Pl
- **Debuggable:** The data is stored as JSON-serialized values.
- **Customizable:** You can serialize and deserialize your own type in your own way.
## Benefits over `@AppStorage`
- You define strongly-typed identifiers in a single place and can use them everywhere.
- You also define the default values in a single place instead of having to remember what default value you used in other places.
- You can use it outside of SwiftUI.
- Comes with Combine publisher.
- Supports many more types, even `Codable`.
- Easy to add support for your own custom types.
- Comes with a convenience SwiftUI `Toggle` component.
## Compatibility
- macOS 10.13+
@ -36,7 +47,7 @@ For a real-world example, see the [Plash app](https://github.com/sindresorhus/Pl
<p>
<p>
<sup>
<a href="https://github.com/sponsors/sindresorhus">Sindres open source work is supported by the community</a>
<a href="https://github.com/sponsors/sindresorhus">Sindre's open source work is supported by the community</a>
</sup>
</p>
<sup>Special thanks to:</sup>