Defaults
Defaults copied to clipboard
💾 Swifty and modern UserDefaults
Is this supposed to work?
`Color.Resolved` is `Codable`, so we should use that for the serialization.
https://developer.apple.com/documentation/swiftui/color/resolve(in:) https://developer.apple.com/documentation/swiftui/color/resolved It should be able to store the color better than what we currently do. We still need to preserve backwards compatibility, so we can first try loading it...
```swift struct User3: Codable, Defaults.Serializable { let name: String let age: String } extension Defaults.Keys { static let user3 = Key("user3", default: .init(name: "Hello", age: "24")) } ... func test2()...
Sometimes you need to store something that is a bit larger, like a icon image. Storing this in UserDefaults would be slow as it has to be decoded each time...
I think we can finally support `@Default` in observable classes. More info: https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md `@Obserable` expands class properties to: ```swift var order: Order? { get { self.access(keyPath: \.order) return _order }...
There's no way to prevent it today, but maybe when Swift supports macros or constant expressions. I have seen many users do: ```swift static let interval = Key("interval", default: nil)...
Some ideas for version 10. It will not happen for a long time. - [ ] Deprecate `.observe()` and `.publisher()`: https://github.com/sindresorhus/Defaults/issues/71
I wonder if we could use macros to simplify some things?
tag project without "v" to be compliant with semantic versioning, used by SPM. Thanks.