react-query
Version:
Hooks for managing, caching and syncing asynchronous and remote data in React
28 lines (27 loc) • 1.07 kB
TypeScript
import { PersistedClient, Persister } from '../persistQueryClient';
interface AsyncStorage {
getItem: (key: string) => Promise<string | null>;
setItem: (key: string, value: string) => Promise<void>;
removeItem: (key: string) => Promise<void>;
}
interface CreateAsyncStoragePersisterOptions {
/** The storage client used for setting an retrieving items from cache */
storage: AsyncStorage;
/** The key to use when storing the cache */
key?: string;
/** To avoid spamming,
* pass a time in ms to throttle saving the cache to disk */
throttleTime?: number;
/**
* How to serialize the data to storage.
* @default `JSON.stringify`
*/
serialize?: (client: PersistedClient) => string;
/**
* How to deserialize the data from storage.
* @default `JSON.parse`
*/
deserialize?: (cachedString: string) => PersistedClient;
}
export declare const createAsyncStoragePersister: ({ storage, key, throttleTime, serialize, deserialize, }: CreateAsyncStoragePersisterOptions) => Persister;
export {};