Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

@StateObject support #158

Closed
MaxDesiatov opened this issue Jul 3, 2020 · 0 comments · Fixed by #260
Closed

@StateObject support #158

MaxDesiatov opened this issue Jul 3, 2020 · 0 comments · Fixed by #260
Labels
SwiftUI compatibility Tokamak API differences with SwiftUI

Comments

@MaxDesiatov
Copy link
Collaborator

Interesting gotcha described here: https://www.mattmoriarity.com/2020-07-03-stateobject-and-observableobject-in-swiftui/

@MaxDesiatov MaxDesiatov added the SwiftUI compatibility Tokamak API differences with SwiftUI label Jul 3, 2020
@MaxDesiatov MaxDesiatov changed the title @StateObject support @StateObject support Aug 16, 2020
MaxDesiatov added a commit that referenced this issue Aug 17, 2020
Resolves #158.

Fixes a bug where `NavigationView` destination was reset after scene phase changes (or any re-renders caused by environment changes for that matter).

This was caused by `@ObservedObject` destination being recreated, now `@StateObject` persists it across re-renders.

The `setter` property of the `ValueStorage` protocol is now moved to a separate `WritableValueStorage` protocol. The reasoning is that `StateObject` doesn't need its wrapped value to be set directly as it operates on it by reference, not by value, thus `StateObject` doesn't need any wrapped value setters.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
SwiftUI compatibility Tokamak API differences with SwiftUI
Development

Successfully merging a pull request may close this issue.

1 participant