UNPKG

haystack-nclient

Version:

Project Haystack Network Client

79 lines (78 loc) 2.25 kB
import { ClientServiceConfig } from '../ClientServiceConfig'; import { WatchApis } from './WatchApis'; import { Record } from '../../util/Record'; /** * The watch subscribe operation. */ export declare const WATCH_SUB_OP = "watchSub"; /** * The watch poll operation. */ export declare const WATCH_POLL_OP = "watchPoll"; /** * The watch unsubscribe operation. */ export declare const WATCH_UNSUB_OP = "watchUnsub"; /** * Watch network calls using Haystack ops. */ export declare class WatchOpApis implements WatchApis { #private; /** * Constructs a new watch operations object. * * @param serviceConfig service configuration. */ constructor(serviceConfig: ClientServiceConfig); /** * Open a new watch. * * @param ids The ids to watch. * @returns The watch open response. * @throws An error if the watch can't be created. */ open(ids: string[], display?: string): Promise<{ id: string; records: Record[]; }>; /** * Add some records to an existing watch. * * @param watchId The id of the watch. * @param ids The record ids to watch. * @returns The watch add response. * @throws An error if the watch can't be found. */ add(watchId: string, ids: string[]): Promise<Record[]>; /** * Poll an existing watch. * * @param watchId The watch id to poll. * @returns The watch poll data. * @throws An error if the watch can't be found. */ poll(watchId: string): Promise<Record[]>; /** * Refresh an existing watch. * * @param watchId The watch id to poll. * @returns The watch poll data. * @throws An error if the watch can't be found. */ refresh(watchId: string): Promise<Record[]>; /** * Remove records from an existing watch. * * @param watchId The id of the watch. * @param ids The record ids to remove. * @throws An error if the watch can't be found. */ remove(watchId: string, ids: string[]): Promise<void>; /** * Close an existing watch. * * @param watchId The id of the watch. * @throws An error if the watch can't be found. */ close(watchId: string): Promise<void>; }