import { Store } from "./store.js"; import { Connection } from "./connection.js"; import { UnsubscribeFunc } from "./types.js"; export type Collection = { state: State; refresh(): Promise; subscribe(subscriber: (state: State) => void): UnsubscribeFunc; }; /** * * @param conn connection * @param key the key to store it on the connection. Must be unique for each collection. * @param fetchCollection fetch the current state. If undefined assumes subscribeUpdates receives current state * @param subscribeUpdates subscribe to updates on the current state * @returns */ export declare const getCollection: (conn: Connection, key: string, fetchCollection: ((conn: Connection) => Promise) | undefined, subscribeUpdates?: (conn: Connection, store: Store) => Promise, options?: { unsubGrace: boolean; }) => Collection; export declare const createCollection: (key: string, fetchCollection: (conn: Connection) => Promise, subscribeUpdates: ((conn: Connection, store: Store) => Promise) | undefined, conn: Connection, onChange: (state: State) => void) => UnsubscribeFunc;