Created
December 1, 2019 15:56
-
-
Save htdangkhoa/c5da1514653b338731eb2abc52fb0db7 to your computer and use it in GitHub Desktop.
Reducer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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