Skip to content

Instantly share code, notes, and snippets.

Created March 31, 2019 14:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
CombineReducer method in Kotlin
// Reducer interface definition
typealias Reducer<ReducerStateType> = (action: Action, state: ReducerStateType?) -> ReducerStateType
// Combine reducers method
fun<T: StateType> combineReducers(vararg reducers: Reducer<T>): Reducer<T> {
return { action, state ->
var newState: T? = state
reducers.forEach { reducer ->
newState = reducer(action, newState)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment