Skip to content
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

Implement StateObject property wrapper #260

Merged
merged 4 commits into from
Aug 17, 2020
Merged

Implement StateObject property wrapper #260

merged 4 commits into from
Aug 17, 2020

Conversation

MaxDesiatov
Copy link
Collaborator

@MaxDesiatov MaxDesiatov commented Aug 15, 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.

@MaxDesiatov MaxDesiatov added the SwiftUI compatibility Tokamak API differences with SwiftUI label Aug 15, 2020
Base automatically changed from separate-subscriptions to main August 15, 2020 17:07
# Conflicts:
#	Sources/TokamakCore/MountedViews/MountedCompositeElement.swift
#	Sources/TokamakCore/StackReconciler.swift
@MaxDesiatov MaxDesiatov marked this pull request as ready for review August 16, 2020 19:33
@MaxDesiatov MaxDesiatov added the bug Something isn't working label Aug 16, 2020
Copy link
Member

@j-f1 j-f1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can’t pretend to fully understand this (I should read the whole codebase some time) but it works!

Bug report moved to #261

@MaxDesiatov
Copy link
Collaborator Author

Yes please, a separate issue would definitely help in tracking this 👍

@MaxDesiatov MaxDesiatov merged commit 2383a17 into main Aug 17, 2020
@MaxDesiatov MaxDesiatov deleted the stateobject branch August 17, 2020 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working SwiftUI compatibility Tokamak API differences with SwiftUI
Development

Successfully merging this pull request may close these issues.

@StateObject support
3 participants