UNPKG

842 BTypeScriptView Raw
1/**
2 * @experimental
3 */
4declare module 'diagnostic_channel' {
5 /**
6 * Returns wether a named channel has subscribers or not.
7 */
8 function hasSubscribers(name: string): boolean;
9
10 /**
11 * Gets or create a diagnostic channel by name.
12 */
13 function channel(name: string): Channel;
14
15 type ChannelListener = (name: string, message: unknown) => void;
16
17 /**
18 * Simple diagnostic channel that allows
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}