Gemini

Краткое руководство


Project maintained by Hukumister Hosted on GitHub Pages — Theme by mattgraham

Основные компоненты

JustReducerStore

Задача

class CounterStore() : JustReducerStore<Action, State, Nothing>(
    initialState = State(),
    reducer = ReducerImpl()
) {

    sealed class Action {
        object Increment : Action()
        object Decrement : Action()
    }

    data class State(
        val count: Int = 0
    )

    class ReducerImpl : Reducer<State, Action> {
        override fun invoke(state: State, action: Action) = when (action) {
            is Action.Increment -> state.copy(count = state.count + 1)
            is Action.Decrement -> state.copy(count = state.count - 1)
        }
    }
}

Самый простой кейс, который не предусматривет сложную логику.