UNPKG

@tanstack/persister

Version:

Utilities for persisting state to local storage, session storage, indexedDB, and more.

18 lines (17 loc) 843 B
/** * Abstract class that defines the contract for an asynchronous state persister. * An async persister is responsible for saving and loading state to a storage medium using asynchronous operations. * * This is useful for scenarios where persistence involves asynchronous APIs, such as IndexedDB, remote storage, or custom async backends. * * Implementations should provide methods to load, save, and clear persisted state for a given key. * * See also: `Persister` for synchronous persister implementations. */ export declare abstract class AsyncPersister<TState, TSelected extends Partial<TState> = TState> { readonly key: string; constructor(key: string); abstract loadState: () => TSelected | undefined; abstract saveState: (state: TState) => void; abstract clearState: (useDefaultState?: boolean) => void; }