You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Good afternoon and thanks for this amazing package. I came across a small error, I can not get the view to be updated when I reset the value to default. When I close the application and open it again, I see that the value is written and is equal to the default.
classSessionStore:ObservableObject{@Default(.loginModel)varloginModel}extensionDefaults.Keys{staticletloginModel=Key<LoginModel?>("loginModel", default:nil)}Button(action:{
sessionStore.loginModel =nil}){HStack{Image(systemName:"flame").frame(width:24)Text("Выйти из аккаунта")}.foregroundColor(.red)}
The text was updated successfully, but these errors were encountered:
You cannot use @Default in an ObservableObject. It's meant to be used in a View.
I agree, it would be useful to allow this, but it's currently not possible to replicate the functionality of @Published, since it uses internal runtime inspection. More info here: https://twitter.com/olebegemann/status/1222866304786423808
There are ways to make this partly work: https://stackoverflow.com/a/59039333/64949 But I'm inclined to wait for WWDC before doing anything more, as I'm hoping it will bring the improvements needed.
sindresorhus
changed the title
The view is not updated when the value is reset to default
Make @Default usable in an ObservableObjectJun 4, 2020
AppStorage property wrappers now work as expected when contained inside an ObservableObject , causing the system to emit the objectWillChange publisher. (65562845)
Good afternoon and thanks for this amazing package. I came across a small error, I can not get the view to be updated when I reset the value to default. When I close the application and open it again, I see that the value is written and is equal to the default.
The text was updated successfully, but these errors were encountered: