SE-0539: Enable Macros to Grant `self` Access for Property Initializers

Yes, maybe I should have left the link to that idea out of the proposal. It could only work if the SwiftUI dataflow team decided to support this use case. Any updates to @State and how it interacts with the environment are not part of this proposal.

I would suggest discussing this example in the original pitch thread to keep this proposal review focused.

Side Discussion

Thanks for the neat idea of putting the environment into a DynamicProperty. From reading the docs on DynamicProperty and environment values I would have never guessed this was possible. I always had assumed the environment wrapper needs to be in a struct conforming to View, otherwise there would be a warning like, "Accessing an Environment value outside of being installed on a View". I'll try it out though!

1 Like