The Store and SwiftUI Integration
Drive views from a TCA store.
What Is a Store?
The Store is the runtime object that holds your feature's state and runs its reducer. A SwiftUI view observes a store to read state and sends actions to it to trigger changes.
The store is the bridge between your pure reducer logic and the live, interactive UI.
import ComposableArchitecture
import SwiftUI
// A Store holds State, runs the Reducer,
// and is observed by SwiftUI views.The StoreOf Type Alias
StoreOf<Feature> is a convenient alias for a store specialized to a feature's state and action types. A view typically holds one as a stored property.
So a counter view stores a StoreOf<CounterFeature>.
import ComposableArchitecture
import SwiftUI
struct CounterView: View {
let store: StoreOf<CounterFeature>
var body: some View {
Text("Count: \(store.count)")
}
}All lessons in this course
- State, Action, and Reducer
- The Store and SwiftUI Integration
- Effects and Dependencies
- Composing and Testing Features