kvision / pl.treksoft.kvision.redux / ReduxStore

ReduxStore

class ReduxStore<S : Any, A : RAction>

A class implementing redux pattern backed by the Redux Kotlin library.

Constructors

<init>

ReduxStore(reducer: ReducerFun<S, A>, initialState: S, vararg middlewares: <ERROR CLASS><S>)
ReduxStore(reducer: <ERROR CLASS><S, A>, initialState: S, vararg middlewares: dynamic)

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

Functions

dispatch

fun dispatch(action: A): Unit

Dispatches a synchronous action object.

fun dispatch(actionCreator: ActionCreator<A, S>): Unit
fun dispatch(actionCreator: ActionCreator<dynamic, S>): <ERROR CLASS>

Dispatches an asynchronous action function.

getState

fun getState(): S

Returns the current state.

subscribe

fun subscribe(listener: (S) -> Unit): () -> Unit

Subscribes a client for the change state notifications.

Extension Functions

createInstance

fun <T> Any?.createInstance(vararg args: dynamic): T

Helper function for creating JavaScript objects from dynamic constructors.