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

32 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 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[], moduleName: string, callback?: Callback<ED>): Promise<void>;
unsub(events: string[], moduleName: string): Promise<void>;
getSubscriberId(): string | undefined;
}
export {};