@photonite/subgraph-sync
Version:
React hooks and components for tracking subgraph synchronization states with Apollo Client
27 lines (26 loc) • 851 B
TypeScript
import { SyncConfig, SyncTarget, UseSubgraphSyncResult } from "../types";
/**
* Hook for tracking subgraph synchronization progress to a target block or timestamp.
*
* @param target - The sync target (block number and/or timestamp)
* @param config - Optional configuration for polling, timeout, retries, and callbacks
*
* @returns Sync state including indexing status, progress, current block, and control functions
*
* @example
* ```tsx
* const syncState = useSubgraphSync(
* { blockNumber: 1000000 },
* {
* pollInterval: 2000,
* timeout: 60000,
* onSyncComplete: () => console.log('Synced!'),
* }
* );
*
* if (syncState.isIndexing) {
* return <div>Progress: {syncState.progress}%</div>;
* }
* ```
*/
export declare const useSubgraphSync: (target: SyncTarget, config?: SyncConfig) => UseSubgraphSyncResult;