UNPKG

react-query-external-sync

Version:

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

38 lines (37 loc) 1.51 kB
import { QueryClient } from "@tanstack/react-query"; import { PlatformOS } from "./platformUtils"; interface useSyncQueriesExternalProps { queryClient: QueryClient; deviceName: string; /** * A unique identifier for this device that persists across app restarts. * This is crucial for proper device tracking, especially if you have multiple devices of the same type. * If you only have one iOS and one Android device, you can use 'ios' and 'android'. * For multiple devices of the same type, ensure this ID is unique and persistent. */ deviceId: string; extraDeviceInfo?: Record<string, string>; socketURL: string; platform: PlatformOS; /** * Enable/disable logging for debugging purposes * @default false */ enableLogs?: boolean; } /** * Hook used by mobile devices to sync query state with the external dashboard * * Handles: * - Connection to the socket server * - Responding to dashboard requests * - Processing query actions from the dashboard * - Sending query state updates to the dashboard */ export declare function useSyncQueriesExternal({ queryClient, deviceName, socketURL, extraDeviceInfo, platform, deviceId, enableLogs, }: useSyncQueriesExternalProps): { connect: () => void; disconnect: () => void; isConnected: boolean; socket: import("socket.io-client").Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>; }; export {};