x-state-manager
Version:
A lightweight state manager built on top of SWR for efficient state management with caching, optimistic updates, and modular architecture. It allows easy global and local state management, automatic data re-fetching on focus, and supports TypeScript
8 lines (5 loc) • 381 B
TypeScript
import { Key, SWRConfiguration, SWRResponse } from 'swr';
type StateFetcher<T> = () => T | Promise<T>;
declare const mutateState: <T>(key: Key, data?: T, shouldRevalidate?: boolean) => Promise<T | undefined>;
declare function createSWRState<T>(key: Key, fetcher: StateFetcher<T> | null, config?: SWRConfiguration<T>): SWRResponse<T, any>;
export { createSWRState, mutateState };