UNPKG

@orbitinghail/sqlsync-react

Version:

SQLSync is a collaborative offline-first wrapper around SQLite. It is designed to synchronize web application state between users, devices, and the edge.

28 lines (27 loc) 1.11 kB
import { ConnectionStatus, DocId, DocType, ParameterizedQuery, Row, SQLSync } from "@orbitinghail/sqlsync-worker"; export declare function useSQLSync(): SQLSync; type MutateFn<M> = (mutation: M) => Promise<void>; type UseMutateFn<M> = (docId: DocId) => MutateFn<M>; type UseQueryFn = <R = Row>(docId: DocId, query: ParameterizedQuery | string) => QueryState<R>; type SetConnectionEnabledFn = (enabled: boolean) => Promise<void>; type UseSetConnectionEnabledFn = (docId: DocId) => SetConnectionEnabledFn; export interface DocHooks<M> { useMutate: UseMutateFn<M>; useQuery: UseQueryFn; useSetConnectionEnabled: UseSetConnectionEnabledFn; } export declare function createDocHooks<M>(docType: DocType<M>): DocHooks<M>; export type QueryState<R> = { state: "pending"; rows?: R[]; } | { state: "success"; rows: R[]; } | { state: "error"; error: Error; rows?: R[]; }; export declare function useQuery<M, R = Row>(docType: DocType<M>, docId: DocId, rawQuery: ParameterizedQuery | string): QueryState<R>; export declare const useConnectionStatus: () => ConnectionStatus; export {};