zippy-store
Version:
A lightweight and versatile global state management solution designed for seamless integration in both JavaScript and React applications. Provides a simple and efficient way to manage shared state across components and even in non-React JavaScript environ
15 lines • 986 B
TypeScript
type State = Record<string, any>;
type Actions = Record<string, (...args: any[]) => any>;
type SubscriberCallback<T extends State> = (newState: T) => void;
type Subscribers<T extends State> = Record<symbol, SubscriberCallback<T>>;
declare const _default: {
createStore: <T extends State, A extends Partial<Actions> = object>(storeKey: string, stateAndActionsFn: (set: (newStateCb: Partial<T> | ((state: T) => Partial<T> | Promise<Partial<T>>)) => void, get: () => T) => T & A, persist?: boolean) => {
dispatch: A;
};
setState: <T extends State, A extends Actions, S extends Subscribers<T>>(storeKey: string, newStateCb: Partial<T> | ((state: T) => Partial<T> | Promise<Partial<T>>)) => Promise<void>;
getState: <T extends State>(storeKey: string) => T;
dispatch: <A extends Actions>(storeKey: string) => A;
subscribe: <T extends State>(key: string, cb: SubscriberCallback<T>) => () => void;
};
export default _default;
//# sourceMappingURL=store.d.ts.map