Skip to content

Instantly share code, notes, and snippets.

@fvilarino
Last active September 18, 2023 18:23
Show Gist options
  • Save fvilarino/f000e2a052194e1583bc5961895cbbb1 to your computer and use it in GitHub Desktop.
Save fvilarino/f000e2a052194e1583bc5961895cbbb1 to your computer and use it in GitHub Desktop.
MVI Framework - Counter ViewModel
class CounterViewModel(
// 1
reducer: CounterReducer = CounterReducer(),
// 2
) : MviViewModel<CounterState, CounterAction>(
reducer = reducer,
initialState = CounterState.initial,
) {
// 3
fun onDecrement() {
dispatch(CounterAction.Decrement)
}
// 4
fun onIncrement() {
dispatch(CounterAction.Increment)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment