1 |
|
2 |
|
3 |
|
4 | declare module 'diagnostic_channel' {
|
5 | |
6 |
|
7 |
|
8 | function hasSubscribers(name: string): boolean;
|
9 |
|
10 | |
11 |
|
12 |
|
13 | function channel(name: string): Channel;
|
14 |
|
15 | type ChannelListener = (name: string, message: unknown) => void;
|
16 |
|
17 | |
18 |
|
19 |
|
20 | class Channel {
|
21 | readonly name: string;
|
22 | readonly hashSubscribers: boolean;
|
23 | private constructor(name: string);
|
24 |
|
25 | /**
|
26 | * Add a listener to the message channel.
|
27 | */
|
28 | subscribe(listener: ChannelListener): void;
|
29 | /**
|
30 | * Removes a previously registered listener.
|
31 | */
|
32 | unsubscribe(listener: ChannelListener): void;
|
33 | }
|
34 | }
|