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
I'm in a process of migration the latest TCA version.
From the documentation, the usage example for @ObservaleState omits the ViewState and uses the State directly:
@ReducerstructFeature{structState{/* ... */}enumAction{/* ... */}varbody:someReducerOf<Self>{// ...}}structFeatureView:View{letstore:StoreOf<Feature>// I would like to keep this ViewState.structViewState:Equatable{// ...init(state:Feature.State){/* ... */}}varbody:someView{WithViewStore(store, observe:ViewState.init){ viewStore inForm{Text(viewStore.count.description)Button("+"){ viewStore.send(.incrementButtonTapped)}}}}}
converts to:
var body: some View {
- WithViewStore(store, observe: ViewState.init) { viewStore in
Form {
- Text(viewStore.count.description)- Button("+") { viewStore.send(.incrementButtonTapped) }+ Text(store.count.description)+ Button("+") { store.send(.incrementButtonTapped) }
}
- }
}
What would be the best approach to keep both the State -> ViewState conversion and @ObservableState?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello!
I'm in a process of migration the latest TCA version.
From the documentation, the usage example for
@ObservaleState
omits the ViewState and uses the State directly:converts to:
What would be the best approach to keep both the State -> ViewState conversion and
@ObservableState
?Beta Was this translation helpful? Give feedback.
All reactions