haystack-nclient
Version:
Project Haystack Network Client
102 lines (101 loc) • 2.68 kB
TypeScript
import { HRef, HDict, HGrid } from 'haystack-core';
import { Subject, SubjectChangedEventHandler } from './Subject';
/**
* A watch subject that batches calls together.
*
* This is used to batch calls together. For instance, let's say 10 watches
* simulatenously watch some records. It would be good to batch this up into one network call.
*/
export declare class BatchSubject implements Subject {
#private;
/**
* Constructs a new batch subject.
*
* @param subject The subject to wrap.
*/
constructor(subject: Subject);
/**
* @returns The display name of the subject.
*/
get display(): string;
/**
* @returns The subject's poll rate.
*/
get pollRate(): number;
/**
* Set the poll rate.
*
* @param pollRate
*/
set pollRate(pollRate: number);
/**
* Refresh the subject's data.
*/
refresh(): Promise<void>;
/**
* Add records to observe.
*
* @param ids The ids to add.
*/
add(ids: string[]): Promise<void>;
/**
* Remove records from the subject.
*
* This is called to stop observing records.
*
* @param ids The ids to remove.
*/
remove(ids: string[]): Promise<void>;
/**
* Invoke a batch operation.
*
* @param op The name of the op.
* @param ids The ids used in the batch operation.
*/
private batchInvoke;
/**
* Queue the batch operation to be invoked.
*
* @param op The name of the op.
* @param ids The ids used in the batch operation.
* @param deferred The deferred promise for this asynchronous operation.
*/
private queueBatchOp;
/**
* Clear the existing batch timer.
*/
private clearBatchTimer;
/**
* Start a new batch timer.
*/
private startBatchTimer;
/**
* Register a callback for changed events.
*
* @param callback The callback used for changed events.
*/
on(callback: SubjectChangedEventHandler): void;
/**
* Unregister the callback for changed events.
*
* @param callback The callback used for changed events.
*/
off(callback: SubjectChangedEventHandler): void;
/**
* Return a record via its id or undefined if it can't be found.
*
* @param id The id to record to get.
* @returns The dict or undefined if it can't be found.
*/
get(id: string | HRef): HDict | undefined;
/**
* Used to manually trigger a watch update.
*
* @param grid A grid of dicts to update.
*/
update(grid: HGrid): Promise<void>;
/**
* Inspect the subject.
*/
inspect(): void;
}