Skip to content

storeApi

storeApi<T, TR>(machine: StoreMachine<T, TR>): StoreMachineApi<T, TR>

Defined in: store-machine-api.ts:40

Creates an API object for a StoreMachine instance, providing event sender functions for each transition.

Type ParameterDefault typeDescription
T-Type of store state
TR extends StoreTransitionRecord<T>StoreTransitionRecord<T>Type of store transitions
ParameterTypeDescription
machineStoreMachine<T, TR>The store machine instance to generate the API for

StoreMachineApi<T, TR>

An object mapping transition keys to sender functions

const todoApi = eventApi(todoStore);
todoApi.addTodo("New task");
todoApi.toggleTodo("123");