oak-frontend-base/lib/features/subscriber.d.ts

34 lines
1.2 KiB
TypeScript

import { EntityDict, OpRecord } from 'oak-domain/lib/types';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { Cache } from './cache';
import { Message } from './message';
import { Feature } from '../types/Feature';
type SubscribeEvent = 'connect' | 'disconnect';
type Callback<ED extends EntityDict & BaseEntityDict> = (event: string, records: OpRecord<ED>[]) => void;
export declare class SubScriber<ED extends EntityDict & BaseEntityDict> extends Feature {
private cache;
private message;
private getSubscribePointFn;
private eventMap;
private url?;
private path?;
private socket?;
private halted;
private socketState;
private eventCallbackMap;
constructor(cache: Cache<ED>, message: Message, getSubscribePointFn: () => Promise<{
url: string;
path: string;
}>);
on(event: SubscribeEvent, callback: (...data: any) => void): void;
off(event: SubscribeEvent, callback: () => void): void;
private emit;
private initSocketPoint;
private connect;
sub(events: string[], callback?: Callback<ED>): Promise<() => void>;
private unsub;
getSubscriberId(): string | undefined;
setHalted(halted: boolean): void;
}
export {};