Programming Tech Brief By HackerNoon
This story was originally published on HackerNoon at: https://hackernoon.com/swiftuis-state-is-now-a-macro-what-it-means-for-you [https://hackernoon.com/swiftuis-state-is-now-a-macro-what-it-means-for-you]. SwiftUI’s @State is now exposed as a macro. Learn what changed, how lazy initialization works, and how to use @State with @Observable models. Check more stories related to programming at: https://hackernoon.com/c/programming [https://hackernoon.com/c/programming]. You can also check exclusive content about #swift [https://hackernoon.com/tagged/swift], #swiftui [https://hackernoon.com/tagged/swiftui], #ios-app-development [https://hackernoon.com/tagged/ios-app-development], #ios-development [https://hackernoon.com/tagged/ios-development], #swift-programming [https://hackernoon.com/tagged/swift-programming], #apple [https://hackernoon.com/tagged/apple], #swift-changes [https://hackernoon.com/tagged/swift-changes], #hackernoon-top-story [https://hackernoon.com/tagged/hackernoon-top-story], and more. This story was written by: @element [https://hackernoon.com/u/element]. Learn more about this writer by checking @element's [https://hackernoon.com/about/element] about page, and for more stories, please visit hackernoon.com [https://hackernoon.com]. TL;DR: SwiftUI’s `@State` is now exposed as a macro, but everyday usage stays almost the same. The biggest practical change is lazy initialization: class instances stored in `@State`, such as `@Observable` view models, are created once for the lifetime of the view’s state storage instead of being re-created whenever the view struct is rebuilt.
100 afleveringen
Reacties
0Wees de eerste die een reactie plaatst
Meld je nu aan en word lid van de Programming Tech Brief By HackerNoon community!