UNPKG

619 BTypeScriptView Raw
1import { UnsubscribeFunc } from "./types.js";
2declare type Listener<State> = (state: State) => void;
3declare type Action<State> = (state: State, ...args: any[]) => Partial<State> | Promise<Partial<State>> | null;
4declare type BoundAction<State> = (...args: any[]) => void;
5export declare type Store<State> = {
6 state: State | undefined;
7 action(action: Action<State>): BoundAction<State>;
8 setState(update: Partial<State>, overwrite?: boolean): void;
9 subscribe(listener: Listener<State>): UnsubscribeFunc;
10};
11export declare const createStore: <State>(state?: State | undefined) => Store<State>;
12export {};