UNPKG

831 BTypeScriptView Raw
1import { Store } from "./store.js";
2import { Connection } from "./connection.js";
3import { UnsubscribeFunc } from "./types.js";
4export declare type Collection<State> = {
5 state: State;
6 refresh(): Promise<void>;
7 subscribe(subscriber: (state: State) => void): UnsubscribeFunc;
8};
9export declare const getCollection: <State>(conn: Connection, key: string, fetchCollection: (conn: Connection) => Promise<State>, subscribeUpdates?: ((conn: Connection, store: Store<State>) => Promise<UnsubscribeFunc>) | undefined) => Collection<State>;
10export declare const createCollection: <State>(key: string, fetchCollection: (conn: Connection) => Promise<State>, subscribeUpdates: ((conn: Connection, store: Store<State>) => Promise<UnsubscribeFunc>) | undefined, conn: Connection, onChange: (state: State) => void) => UnsubscribeFunc;