1 | export type HubCapsule = {
|
2 | channel: string;
|
3 | payload: HubPayload;
|
4 | source: string;
|
5 | patternInfo?: string[];
|
6 | };
|
7 | export type HubPayload = {
|
8 | event: string;
|
9 | data?: any;
|
10 | message?: string;
|
11 | };
|
12 | export type HubCallback = (capsule: HubCapsule) => void;
|
13 | export type LegacyCallback = {
|
14 | onHubCapsule: HubCallback;
|
15 | };
|
16 | export declare class HubClass {
|
17 | name: string;
|
18 | private listeners;
|
19 | private patterns;
|
20 | protectedChannels: string[];
|
21 | constructor(name: string);
|
22 | /**
|
23 | * Used internally to remove a Hub listener.
|
24 | *
|
25 | * @remarks
|
26 | * This private method is for internal use only. Instead of calling Hub.remove, call the result of Hub.listen.
|
27 | */
|
28 | private _remove;
|
29 | /**
|
30 | * @deprecated Instead of calling Hub.remove, call the result of Hub.listen.
|
31 | */
|
32 | remove(channel: string | RegExp, listener: HubCallback): void;
|
33 | /**
|
34 | * Used to send a Hub event.
|
35 | *
|
36 | * @param channel - The channel on which the event will be broadcast
|
37 | * @param payload - The HubPayload
|
38 | * @param source - The source of the event; defaults to ''
|
39 | * @param ampSymbol - Symbol used to determine if the event is dispatched internally on a protected channel
|
40 | *
|
41 | */
|
42 | dispatch(channel: string, payload: HubPayload, source?: string, ampSymbol?: Symbol): void;
|
43 | /**
|
44 | * Used to listen for Hub events.
|
45 | *
|
46 | * @param channel - The channel on which to listen
|
47 | * @param callback - The callback to execute when an event is received on the specified channel
|
48 | * @param listenerName - The name of the listener; defaults to 'noname'
|
49 | * @returns A function which can be called to cancel the listener.
|
50 | *
|
51 | */
|
52 | listen(channel: string | RegExp, callback?: HubCallback | LegacyCallback, listenerName?: string): () => void;
|
53 | private _toListeners;
|
54 | }
|
55 | export declare const Hub: HubClass;
|