resso
Version:
The simplest React state manager
18 lines (16 loc) • 545 B
TypeScript
type VoidFn = () => void;
type SetKeyAction<V> = V | ((prev: V) => V);
type SetDataAction<V> = Partial<V> | ((prev: V) => Partial<V>);
type SetStore<Data> = {
<K extends keyof Data>(key: K, val: SetKeyAction<Data[K]>): void;
(payload: SetDataAction<Data>): void;
};
type Store<Data> = Data & SetStore<Data>;
declare let run: (fn: VoidFn) => void;
declare const resso: {
<Data extends Record<string, unknown>>(data: Data): Store<Data>;
config({ batch }: {
batch: typeof run;
}): void;
};
export { resso as default };