35 lines
1.3 KiB
TypeScript
35 lines
1.3 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';
|
|
import SocketPoint from './socketPoint';
|
|
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 socketPoint;
|
|
private eventMap;
|
|
private url?;
|
|
private path?;
|
|
private socket?;
|
|
private halted;
|
|
private reconnectInterval;
|
|
private reconnectTimer;
|
|
private count;
|
|
private socketState;
|
|
private eventCallbackMap;
|
|
constructor(cache: Cache<ED>, message: Message, socketPoint: SocketPoint);
|
|
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 {};
|