Package-level declarations

Types

Link copied to clipboard
interface ChildReducer<in ParentState, in Action : Any, out ChildState>

A transformed Reducer for combineReducers that returns the next child state, given the parent state and an action to handle.

Link copied to clipboard
fun interface Middleware<State, Action : Any>

A middleware that can wrap the Store.dispatch method.

Link copied to clipboard

A scope for a Middleware.

Link copied to clipboard
interface Reducer<State, in Action : Any>

A reducer that returns the next state, given the current state and an action to handle.

Link copied to clipboard
interface Store<out State, in Action : Any>

A store that holds a state. The only way to change the state is to dispatch an action.

Functions

Link copied to clipboard

Transforms the Reducer to a ChildReducer for combineReducers. The mapToChildState transforms the ParentState to the ChildState.

Transforms the Reducer to a ChildReducer for combineReducers. The mapToChildAction transforms the ParentAction to the ChildAction, and the mapToChildState transforms the ParentState to the ChildState. If the mapToChildAction returns null, the reducer will not be called.

Link copied to clipboard
fun <State, Action : Any, S> combineReducers(vararg reducers: ChildReducer<State, Action, S>, transform: (List<S>) -> State): Reducer<State, Action>

Turns multiple Reducers into a single Reducer function. The resulting Reducer calls every child Reducer, and gathers their results into a single state object with the transform.

fun <State, Action : Any, S1, S2> combineReducers(reducer1: ChildReducer<State, Action, S1>, reducer2: ChildReducer<State, Action, S2>, transform: (S1, S2) -> State): Reducer<State, Action>

Turns two Reducers into a single Reducer function. The resulting Reducer calls every child Reducer, and gathers their results into a single state object with the transform.

fun <State, Action : Any, S1, S2, S3> combineReducers(reducer1: ChildReducer<State, Action, S1>, reducer2: ChildReducer<State, Action, S2>, reducer3: ChildReducer<State, Action, S3>, transform: (S1, S2, S3) -> State): Reducer<State, Action>

Turns three Reducers into a single Reducer function. The resulting Reducer calls every child Reducer, and gathers their results into a single state object with the transform.

fun <State, Action : Any, S1, S2, S3, S4> combineReducers(reducer1: ChildReducer<State, Action, S1>, reducer2: ChildReducer<State, Action, S2>, reducer3: ChildReducer<State, Action, S3>, reducer4: ChildReducer<State, Action, S4>, transform: (S1, S2, S3, S4) -> State): Reducer<State, Action>

Turns four Reducers into a single Reducer function. The resulting Reducer calls every child Reducer, and gathers their results into a single state object with the transform.

fun <State, Action : Any, S1, S2, S3, S4, S5> combineReducers(reducer1: ChildReducer<State, Action, S1>, reducer2: ChildReducer<State, Action, S2>, reducer3: ChildReducer<State, Action, S3>, reducer4: ChildReducer<State, Action, S4>, reducer5: ChildReducer<State, Action, S5>, transform: (S1, S2, S3, S4, S5) -> State): Reducer<State, Action>

Turns five Reducers into a single Reducer function. The resulting Reducer calls every child Reducer, and gathers their results into a single state object with the transform.

Link copied to clipboard
fun <State, Action : Any> Reducer(initialState: State, reducer: (acc: State, action: Action) -> State): Reducer<State, Action>

Creates a Reducer that returns the next state, given the current state and an action to handle.

Link copied to clipboard
fun <State, Action : Any> Store(reducer: Reducer<State, Action>, initialState: State = reducer.initialState, middlewares: List<Middleware<State, Action>> = emptyList(), coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.Default)): Store<State, Action>

Creates a Store that holds the state.