home-assistant-js-websocket
Version:
Home Assistant websocket client
11 lines (10 loc) • 832 B
TypeScript
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;