UNPKG

@tanstack/react-optimistic

Version:

React hooks for optimistic updates

40 lines (39 loc) 1.49 kB
import { SyncConfig } from '@tanstack/optimistic'; import { Row, ShapeStreamOptions } from '@electric-sql/client'; export type * from '@tanstack/optimistic'; export * from './useCollection.cjs'; export type { Collection } from '@tanstack/optimistic'; /** * Extended SyncConfig interface with ElectricSQL-specific functionality */ export interface ElectricSync extends SyncConfig { /** * Wait for a specific transaction ID to be synced * @param txid The transaction ID to wait for * @param timeout Optional timeout in milliseconds (defaults to 30000ms) * @returns Promise that resolves when the txid is synced */ awaitTxid: (txid: number, timeout?: number) => Promise<boolean>; /** * Get the sync metadata for insert operations * @returns Record containing primaryKey and relation information */ getSyncMetadata: () => Record<string, unknown>; } /** * Creates an ElectricSQL sync configuration * * @param streamOptions - Configuration options for the ShapeStream * @param options - Options for the ElectricSync configuration * @returns ElectricSync configuration */ export declare function createElectricSync<T extends Row<unknown> = Row>(streamOptions: ShapeStreamOptions, options: ElectricSyncOptions): ElectricSync; /** * Configuration options for ElectricSync */ export interface ElectricSyncOptions { /** * Array of column names that form the primary key of the shape */ primaryKey: Array<string>; }