UNPKG

@vegajs/vortex

Version:

🌀 A next-gen, lightweight state management library for JavaScript and TypeScript.

24 lines (23 loc) • 975 B
import type { DefineStore, NonFunctionKeys, UnknownState, UnwrappedState } from '../../types'; import type { PersistStorage } from './types'; export interface PersistOptions<T> { key: string; version?: number; migrations?: Record<number, (state: UnwrappedState<T>) => UnwrappedState<T>>; properties?: NonFunctionKeys<T>[]; storage?: PersistStorage; onBeforeHydration?: () => void; onHydrated?: (state: UnwrappedState<T>) => void; onHydrationError?: (error: unknown) => void; } export interface PersistPlugin<T extends UnknownState> { remove: () => void; apply: (store: DefineStore<T>) => () => void; } type GlobalPersistSetting = { isReady: boolean; globalStorage?: PersistStorage | null; }; export declare const configurePersistPlugin: ({ globalStorage, }: Omit<GlobalPersistSetting, "isReady">) => void; export declare const persistPlugin: <T extends UnknownState>(options: PersistOptions<T>) => PersistPlugin<T>; export {};