@jingoz/zlight
Version:
一个轻量级的仿 zustand 的 React 状态管理库
20 lines (16 loc) • 506 B
text/typescript
/**
* The listener is called with the new state and the previous state
*/
export type TListener<S> = (state: S, prev: S) => void
/**
* The setState function, accepts a partial state
*/
export type TSetStateFn<S> = (partial: S | Partial<S> | { _(state: S): S | Partial<S> }['_']) => void
/**
* The getState function
*/
export type TGetStateFn<S> = () => S
/**
* The creator function type
*/
export type TCreatorFn<S> = (setState: TSetStateFn<S>, getState: TGetStateFn<S>) => S