zustand-ards
Version:
A library of simple opinionated utilities for zustand. zustand-ards are typesafe and designed to be easily added to an existing codebase to improve the experience of developing with zustand.
18 lines (15 loc) • 898 B
TypeScript
import * as __types from './types';
import { ReadonlyStoreApi } from './types';
export * from './types';
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
export * from './array-selector';
export * from './default-shallow';
/**
* This enchances the traditional store hook so access to the provided store is shallow by default.
* It also adds another style of selector: an array of keys from the provided store.
*/
declare const withZustandards: <T>(storeHook: UseBoundStoreWithEqualityFn<ReadonlyStoreApi<T>>) => (<U, A extends (keyof T)[]>(selector: A, equals?: ((a: __types.PartObjFromArrOfKeys<T, A>, b: __types.PartObjFromArrOfKeys<T, A>) => boolean) | undefined) => __types.PartObjFromArrOfKeys<T, A>) & {
(): T;
<U_1>(selector: (state: T) => U_1, equalityFn?: ((a: U_1, b: U_1) => boolean) | undefined): U_1;
} & ReadonlyStoreApi<T>;
export { withZustandards };