-
-
Notifications
You must be signed in to change notification settings - Fork 121
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
Support using @Default
in @Observable
classes
#142
Comments
Any updates on this? iOS17 is just around the corner and I'm in the process of migrating |
This will unfortunately not happen soon unless someone contributes the functionality. Creating a macro is not easy, and the macro system is still in flux. Even the built-in For now, you could use either of these packages. They work with |
This addresses sindresorhus#142 by creating a new macro that can be used inside `@Observable` classes. The macro is implemented in a new `DefaultsMacros` module. The decision to do so is based on the introduction of a new dependency on `swift-syntax`, and to keep the main module dependency-free.
This addresses sindresorhus#142 by creating a new macro that can be used inside `@Observable` classes. The macro is implemented in a new `DefaultsMacros` module. The decision to do so is based on the introduction of a new dependency on `swift-syntax`, and to keep the main module dependency-free.
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: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.The text was updated successfully, but these errors were encountered: