@statesync/core / RevisionSyncHandle
Interface: RevisionSyncHandle
Defined in: engine.ts:116
A handle for controlling a running revision-based sync loop.
Returned by createRevisionSync. The sync loop does not start automatically -- call start to begin subscribing and fetching. Call stop to tear down all subscriptions and timers.
Example
const handle = createRevisionSync(options);
await handle.start();
// Later, force a manual refresh:
await handle.refresh();
// Teardown:
handle.stop();Methods
getLocalRevision()
getLocalRevision(): Revision;Defined in: engine.ts:152
Returns the most recently applied local revision.
Before the first successful snapshot apply, this returns ZERO_REVISION ("0").
Returns
The current local Revision.
refresh()
refresh(): Promise<void>;Defined in: engine.ts:144
Manually triggers a snapshot fetch and apply cycle.
Concurrent calls are coalesced: if a refresh is already in flight, the new request is queued and executed once the current one completes. If the handle is stopped, this is a no-op.
Returns
Promise<void>
Throws
If the snapshot fetch or apply fails.
start()
start(): Promise<void>;Defined in: engine.ts:127
Starts the sync loop: subscribes to invalidation events and performs the initial snapshot fetch.
Must be called exactly once. Calling start() after stop() throws. Calling start() while already started is a no-op.
Returns
Promise<void>
Throws
If subscription fails or the initial snapshot fetch fails. On failure the handle is reset and can be retried by calling start() again.
stop()
stop(): void;Defined in: engine.ts:134
Stops the sync loop: unsubscribes from invalidation events, cancels pending throttled/debounced refreshes, and marks the handle as stopped.
Safe to call multiple times; subsequent calls are no-ops.
Returns
void
