UNPKG

924 BTypeScriptView Raw
1export declare type HubCapsule = {
2 channel: string;
3 payload: HubPayload;
4 source: string;
5 patternInfo?: string[];
6};
7export declare type HubPayload = {
8 event: string;
9 data?: any;
10 message?: string;
11};
12export declare type HubCallback = (capsule: HubCapsule) => void;
13export declare type LegacyCallback = {
14 onHubCapsule: HubCallback;
15};
16export declare class HubClass {
17 name: string;
18 private listeners;
19 private patterns;
20 protectedChannels: string[];
21 constructor(name: string);
22 remove(channel: string | RegExp, listener: HubCallback): void;
23 dispatch(channel: string, payload: HubPayload, source?: string, ampSymbol?: Symbol): void;
24 listen(channel: string | RegExp, callback?: HubCallback | LegacyCallback, listenerName?: string): () => void;
25 private _toListeners;
26}
27export declare const Hub: HubClass;
28/**
29 * @deprecated use named import
30 */
31export default Hub;