@awhere/api
Version:
The awesome aWhere API for JavaScript.
31 lines (30 loc) • 889 B
TypeScript
import { Socket } from 'socket.io-client';
export declare enum WatchEvent {
change = "change",
create = "create",
update = "update",
delete = "delete",
restore = "restore",
erase = "erase"
}
interface IWatcherPayload {
parentId?: string;
itemIds: string[];
}
export interface IWatcherMessage {
event: WatchEvent;
payload: IWatcherPayload | any;
[key: string]: any;
}
export declare class Watcher {
protected itemId?: string;
protected namepsace: string;
protected socket: Socket;
protected listEvents: any;
protected generateId: (namespace?: string) => string;
constructor(socket: Socket, namespace: string, itemId?: string);
on(event: WatchEvent | keyof typeof WatchEvent, callback: (msg: IWatcherMessage) => void): void;
off(event: WatchEvent | keyof typeof WatchEvent): void;
unwatch(): void;
}
export {};