Replies: 2 comments 1 reply
-
Hello @alwaysblu! Unfortunately, as convenient as they are, they both share the same issue: you can access by mistake a property that will not be effectively observed from your view, leading to disparities between your UI and your model. Your version is likely more resilient to this issue because you're starting from a complete state, so it is less likely to tap on the excluded property than to tap on some unaccounted new property with my proposal. Given the way Going back to the issue that motivated your wrapper, it could probably be alleviated by using a Because of its liability and the I would also like to mention that there are some preliminary works around a better integration of Navigation in TCA. It is possible that new property wrappers will be introduced to model these specific states, and maybe yours will find its place more naturally at this moment, in this form or another. |
Beta Was this translation helpful? Give feedback.
-
Hello, @tgrapperon thanks for your comment! My motivation for creating this property wrapper is to prevent unwanted updates to the View when a specific State such as localState is changed. I think that the responsibility of preventing access to match the View and model you mentioned is the responsibility of the access control such as 'private', not the property wrapper. and I'm not sure if it's right to have a private value as a property in State. Thanks for letting me know about the ViewState code. If a new navigation way comes out, So I agree with you about adding this code to the library. I would really appreciate it if you leave your opinion on my opinion again next time Thank you |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I implemented a property wrapper called
AlwaysEquatable
.AlwaysEquatable
property wrapper type that always returns true meaning the same valuewhen performing a comparison operation (==), even if the values are different.
This type can solve the problem of popping at a specific depth when using NavigationLink,
which occurs when the local state in the global state changes.
For example, if you write the code as below,
objectWillChange.send()
of ViewStore will not be calledwhen the value of displayName or localState is changed.
Experiment
This is a navigation experiment project. (branch -> pop_case)
The project is simple.
There is a 2 depth navigationLink in the first NavigationView
and a 2nd NavigationView which has a 3 depth navigationLink in the 2 depth navigationLink of the first NavigationView.
That is, a total of 5 depths.
And some depths each have a button to change the random state.
Case 1
For convenience, I will call these views root, depth 1, 2, 3, 4, 5
An unexpected problem arises here.
When the state of depth 2, 3, 4, 5 except for the state of depth 1 is changed, an unexpected pop occurs.
The initial value of random state is 0, and when the reset button is pressed, it is initialized to a random value between 0 and 100.
Case 2
In this case, an unexpected pop occurs only when the reset button of depth 2 is clicked.
Case 3
In this case, an unexpected pop occurs only when the reset button of depth 4, 5 is clicked.
Unlike case 2, when an unexpected pop occurs, the screen is converted to depth 3 instead of depth 1.
Case 4
In this case, there is no unexpected pop.
Experiment conclustion
An unexpected pop can be prevented by applying the
AlwaysEquatable
property wrapper to the local state in the State where the navigationView exists.I would like to discuss whether this property wrapper will be removed in the future,
If this property wrapper is added to the TCA.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions