ReduxStore

class ReduxStore<S : Any, A>(reducer: <Error class: unknown class><S, A>, initialState: S, middlewares: dynamic) : ObservableState<S>

A class implementing redux pattern backed by the original Redux JS library.

Parameters

S

redux state type

A

redux action type

reducer

a reducer function

initialState

an initial state

middlewares

a list of optional Redux JS middlewares

Constructors

Link copied to clipboard
constructor(reducer: <Error class: unknown class><S, A>, initialState: S, vararg middlewares: dynamic)

Creates a Redux store with given reducer function and initial state.

Properties

Link copied to clipboard
val <S> ObservableState<S>.stateFlow: <Error class: unknown class><S>

Extension property returning a StateFlow for an ObservableState.

Functions

Link copied to clipboard
fun dispatch(action: A): <Error class: unknown class>

Dispatches a synchronous action object.

fun dispatch(actionCreator: ActionCreator<dynamic, S>): <Error class: unknown class>

Dispatches an asynchronous action function.

Link copied to clipboard
open override fun getState(): S

Get current state.

Link copied to clipboard
fun <S, T> ObservableState<S>.sub(contextWidget: Widget? = null, extractor: (S) -> T): ObservableState<T>

Returns a sub-store of the original ObservableState

Link copied to clipboard
open override fun subscribe(observer: (S) -> Unit): () -> Unit

Subscribe for the state change notifications. Calls the observer with the current state.