json-joy
Version:
Collection of libraries for building collaborative editing apps.
21 lines (20 loc) • 697 B
TypeScript
export interface SyncStore<T> {
subscribe: SyncStoreSubscribe;
getSnapshot: () => T;
}
export type SyncStoreSubscribe = (callback: () => void) => SyncStoreUnsubscribe;
export type SyncStoreUnsubscribe = () => void;
export declare class FanoutSyncStore<T> implements SyncStore<T> {
readonly getSnapshot: () => T;
private readonly fanout;
readonly subscribe: SyncStoreSubscribe;
constructor(getSnapshot: () => T);
}
export declare class ValueSyncStore<V> implements SyncStore<V> {
value: V;
private readonly fanout;
readonly subscribe: SyncStoreSubscribe;
constructor(value: V);
readonly getSnapshot: () => V;
next(value: V, force?: boolean): void;
}