zustand-utils
Version:
some utils for zustand
15 lines (14 loc) • 651 B
TypeScript
import { StoreApi } from 'zustand';
declare type WithoutCallSignature<T> = {
[K in keyof T]: T[K];
};
/**
* 该函数接收四个参数:key,value 、 deps setStoreState
* @param {key}:需要更新的 Store 中的 key
* @param value:需要更新的值
* @param deps:依赖项数组,默认为 [value]
* @param setStoreState:一个可选的回调函数,用于更新 Store 状态
*/
export type UseStoreUpdater<T> = (key: keyof T, value: any, deps?: any[], setStateFn?: (state: T) => void) => void;
export declare const createStoreUpdater: <T>(storeApi: WithoutCallSignature<StoreApi<T>>) => UseStoreUpdater<T>;
export {};