Created
April 13, 2022 17:19
-
-
Save linean/737ed4adda726b15e11549d03628877b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ViewModel { | |
val state = StateReducerFlow( | |
initialState = State(), | |
reduceState = ::reduceState | |
) | |
private fun reduceState(currentState: State, event: Event): State { | |
return when (event) { | |
is Increment -> currentState.copy(counter = currentState.counter + 1) | |
is Decrement -> currentState.copy(counter = currentState.counter - 1) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Article: https://maciej-sady.medium.com/all-you-need-for-mvi-is-kotlin-how-to-reduce-without-reducer-5e986856610f
Project: https://github.com/linean/StateReducerFlow