siegel
Version:
Web application development ecosystem
12 lines (11 loc) • 573 B
TypeScript
import type { StoreShouldUpdate, StateWithUpdater, ActionsUnbinded, ActionsBinded, HookStore } from './types';
declare function createStore<S extends Obj, A extends ActionsUnbinded<S>>(initialStateResolver: () => S, actions: A): {
/** Store */
store: HookStore<S, A>;
/** Hook which subscribes component to the store */
useStore(shouldUpdate?: StoreShouldUpdate<StateWithUpdater<S>>): readonly [StateWithUpdater<S>, ActionsBinded<A>];
/** Resets store to its default state */
reset(): void;
};
export default createStore;
export type { HookStore };