UNPKG

react-query-external-sync

Version:

A tool for syncing React Query state to an external Dev Tools

26 lines (25 loc) 1.67 kB
import type { QueryClient, QueryKey } from "@tanstack/react-query"; /** * Storage interface that storage implementations should follow * Supports both MMKV-style (primitives + strings) and AsyncStorage-style (strings only) */ export interface StorageInterface { set: (key: string, value: string | number | boolean) => void | Promise<void>; delete: (key: string) => void | Promise<void>; } /** * Handles storage queries by detecting the storage type and delegating to the unified handler * This function assumes the queryKey is already confirmed to be a storage query * Expected format: ['#storage', 'storageType', 'key'] * Supported storage types: 'mmkv', 'asyncstorage', 'async-storage', 'async', 'securestorage', 'secure-storage', 'secure' * Returns true if it was handled, false if it should fall back to regular query update */ export declare function handleStorageUpdate(queryKey: QueryKey, data: unknown, queryClient: QueryClient, storage?: StorageInterface, enableLogs?: boolean, deviceName?: string): boolean; /** * Handles storage query removal by detecting the storage type and delegating to the unified removal handler * This function assumes the queryKey is already confirmed to be a storage query * Expected format: ['#storage', 'storageType', 'key'] * Supported storage types: 'mmkv', 'asyncstorage', 'async-storage', 'async', 'securestorage', 'secure-storage', 'secure' * Returns true if it was handled, false if it should fall back to regular query removal */ export declare function handleStorageRemoval(queryKey: QueryKey, queryClient: QueryClient, storage?: StorageInterface, enableLogs?: boolean, deviceName?: string): boolean;