UNPKG

home-assistant-js-websocket

Version:
11 lines (10 loc) 832 B
import { Store } from "./store"; import { Connection } from "./connection"; import { UnsubscribeFunc } from "./types"; export declare type Collection<State> = { state: State; refresh(): Promise<void>; subscribe(subscriber: (state: State) => void): UnsubscribeFunc; }; export declare const getCollection: <State>(conn: Connection, key: string, fetchCollection: (conn: Connection) => Promise<State>, subscribeUpdates?: ((conn: Connection, store: Store<State>) => Promise<UnsubscribeFunc>) | undefined) => Collection<State>; export 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;