Skip to content

Instantly share code, notes, and snippets.

@htdangkhoa
Created December 1, 2019 15:56
Show Gist options
  • Save htdangkhoa/c5da1514653b338731eb2abc52fb0db7 to your computer and use it in GitHub Desktop.
Save htdangkhoa/c5da1514653b338731eb2abc52fb0db7 to your computer and use it in GitHub Desktop.
Reducer
class CounterReducer: Reducer<CounterState> {
override fun reduce(state: CounterState, action: Action): CounterState {
return when (action) {
CounterAction.INCREASE -> state.copy(number = state.number + 1)
CounterAction.DECREASE -> state.copy(number = state.number - 1)
else -> state
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment