1 |
|
2 | import { EventEmitter } from 'events';
|
3 | import { PubSubEngine } from './pubsub-engine';
|
4 | export interface PubSubOptions {
|
5 | eventEmitter?: EventEmitter;
|
6 | }
|
7 | export declare class PubSub<Events extends {
|
8 | [event: string]: unknown;
|
9 | } = Record<string, never>> extends PubSubEngine {
|
10 | protected ee: EventEmitter;
|
11 | private subscriptions;
|
12 | private subIdCounter;
|
13 | constructor(options?: PubSubOptions);
|
14 | publish<K extends keyof Events>(triggerName: K & string, payload: Events[K] extends never ? any : Events[K]): Promise<void>;
|
15 | subscribe<K extends keyof Events>(triggerName: K & string, onMessage: (...args: any[]) => void): Promise<number>;
|
16 | unsubscribe(subId: number): void;
|
17 | }
|