Files
t3code/apps/web/src/stateSource.ts
T
2026-02-20 09:58:01 +00:00

22 lines
579 B
TypeScript

import type {
NativeApi,
StateBootstrapResult,
StateCatchUpInput,
StateCatchUpResult,
StateEvent,
} from "@t3tools/contracts";
export interface StateSource {
bootstrap(): Promise<StateBootstrapResult>;
catchUp(input: StateCatchUpInput): Promise<StateCatchUpResult>;
onEvent(listener: (event: StateEvent) => void): () => void;
}
export function createStateSource(api: NativeApi): StateSource {
return {
bootstrap: () => api.state.bootstrap(),
catchUp: (input) => api.state.catchUp(input),
onEvent: (listener) => api.state.onEvent(listener),
};
}