Skip to content
Discussion options

You must be logged in to vote

Hey @Nerkyator! The type of the ViewStore's state is the type of the "observed" state. In your case, you're observing \.selectedScreen only, so the value that ViewStore will observe and present will be a Screen.

In some ways, it is functionally similar to scoping to a smaller store that you're observing.
When you replace by { $0 }, you observe the whole state, so the ViewStore presents a ContentViewFeature.State.

You can check the "Performance" article where a dedicated type (ViewState) is also used. In your case, observing Screen only was the optimal choice (even if in this case, it's be similar to observing the whole state!).

Please also note that you can derive a binding by pointing to…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Nerkyator
Comment options

Answer selected by Nerkyator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants