yes, I think that would work. I tried that for aw...
# redux
p
yes, I think that would work. I tried that for awhile and didn't find it too useful, but if your breaking it down by screen that may be beneficial to make sure all the actions are handled. These helper function would make it easy to declared a "sealedReducer" :
Copy code
typealias SealedReducer<TState, TAction> = (state: TState, action: TAction) -> TState
typealias SealedReducer<TState, TAction> = (state: TState, action: TAction) -> TState

inline fun <TState, reified TAction> sealedReducer(crossinline reducer: SealedReducer<TState, TAction>): Reducer<TState> {
    return {state, action ->
        if (action is TAction) {
            reducer(state, action)
        } else {
            state
        }
    }
}
sealed class LoginScreenAction
class LoginButtonTap: LoginScreenAction()

val loginScreenReducer = sealedReducer<TestState, LoginScreenAction> { state, action ->
    when(action) {
        is LoginButtonTap -> state
    }
}
@andreworobator I made some small changes to this code. sealedReducer will need 2 type params. Think I will put this into the next release
👌🏾 1