-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Fix for freezes in MenuBarExtra and NavigationStack #158
Conversation
|
||
var value: Value { | ||
get { Defaults[key] } | ||
set { | ||
objectWillChange.send() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any harm in keeping this? Unless I'm missing something. See: #144 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that is kept, the menubar will still freeze for some reason. Removing it fixes that, and doesn't seem to affect anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Wouter01 Removing objectWillChange.send()
broke animations when using withAnimation
, so I will have to add it back unless you can think of a better solution.
Reproduction: Fixture.zip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using @StateObject
looks good in this case, thanks for the fix!
This PR changes the internal code of the
@Default
property wrapper, so it uses StateObject instead of ObservableObject. This fixes #144As StateObject is not supported in SwiftUI 1.0, an
@available
has been added. This could be a breaking change for projects with the minimum target set to iOS 13.0 etc.Instead of creating a new model when the key changes (which is what happened previously), the key will now be changed in the model itself. An extra check is done to make sure that the observers are not restarted too often.