ViewModelWithState
public protocol ViewModelWithState : ViewModel
A special case of ViewModel
used to select part of the Katana app state
that is of interest for the View.
struct CounterState: State {
var counter: Int = 0
}
struct CounterViewModel: ViewModelWithState {
var countDescription: String
init(state: CounterState) {
self.countDescription = "the counter is at \(state.counter)"
}
}
-
The type of the State for this ViewModel
Declaration
Swift
associatedtype S : State
-
Instantiate a ViewModelWithState given the Katana app state.
Declaration
Swift
init?(state: S)