Skip to content

Show we have one big AppState or multiple small FeatureState ? #378

Answered by mbrandonw
mackoj asked this question in Q&A
Discussion options

You must be logged in to vote

Having a state struct and enum action per screen is definitely not a bad thing to do. TCA encourages it. It's the whole reason we have .pullback on reducers and .scope on Store 🙂

The problem you are seeing is due to the fact that in AppScreen you are observing all of AppState:

WithViewStore(self.store) { viewStore in

This means when anything changes in AppState it will cause this view to be recomputed. However, in that view you never actually access the state from the view store. You only need to send actions. So, what you can do is chisel away all the state so that you are only observing a void value:

WithViewStore(self.store.stateless) { viewStore in

That should fix your over-rendering …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@mackoj
Comment options

@mackoj
Comment options

@mbrandonw
Comment options

@mackoj
Comment options

Answer selected by mackoj
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