@statesync/core / SnapshotProvider
Interface: SnapshotProvider<T>
Defined in: types.ts:153
Fetches the latest authoritative snapshot for a given topic.
The engine calls getSnapshot whenever a refresh is needed (after an invalidation or on initial start).
Example
ts
const provider: SnapshotProvider<UserProfile> = {
async getSnapshot() {
const res = await fetch('/api/user-profile/snapshot');
return res.json(); // { revision, data }
},
};Type Parameters
| Type Parameter | Description |
|---|---|
T | The application-specific snapshot data type. |
Methods
getSnapshot()
ts
getSnapshot(): Promise<SnapshotEnvelope<T>>;Defined in: types.ts:161
Retrieves the most recent snapshot from the authoritative source.
Returns
Promise<SnapshotEnvelope<T>>
A promise resolving to a SnapshotEnvelope containing the revision and the snapshot payload.
Throws
If the underlying fetch or data retrieval fails.
