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:
var order: Order? {
get {
self.access(keyPath: \.order)
return _order
}
set {
self.withMutation(keyPath: \.order) {
_order = newValue
}
}
}
So we could make a macro that could be attached a property and it would generate similar code, but also integrate with Defaults
.
It would be nice if @Default
could be reused, but I'm not sure whether it's possible.
I'm open to other ideas on how to make us able to integrate Defaults into @Observable
classes.
There is no rush with this one. We will probably not do anything about it until after iOS 17 is out.
After iOS 17 is out, we could also maybe try to expand @AppStorage
and see if it's a macro then, and if so, what it generates.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too