1 | import { AnyJson } from '@salesforce/ts-types';
|
2 | type callback = (data: any) => Promise<void>;
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | export declare class Lifecycle {
|
25 | private readonly listeners;
|
26 | static readonly telemetryEventName = "telemetry";
|
27 | static readonly warningEventName = "warning";
|
28 | private debug;
|
29 | private constructor();
|
30 | /**
|
31 | * return the package.json version of the sfdx-core library.
|
32 | */
|
33 | static staticVersion(): string;
|
34 | /**
|
35 | * Retrieve the singleton instance of this class so that all listeners and emitters can interact from any library or tool
|
36 | */
|
37 | static getInstance(): Lifecycle;
|
38 | /**
|
39 | * return the package.json version of the sfdx-core library.
|
40 | */
|
41 | version(): string;
|
42 | /**
|
43 | * Remove all listeners for a given event
|
44 | *
|
45 | * @param eventName The name of the event to remove listeners of
|
46 | */
|
47 | removeAllListeners(eventName: string): void;
|
48 | /**
|
49 | * Get an array of listeners (callback functions) for a given event
|
50 | *
|
51 | * @param eventName The name of the event to get listeners of
|
52 | */
|
53 | getListeners(eventName: string): callback[];
|
54 | /**
|
55 | * Create a listener for the `telemetry` event
|
56 | *
|
57 | * @param cb The callback function to run when the event is emitted
|
58 | */
|
59 | onTelemetry(cb: (data: Record<string, unknown>) => Promise<void>): void;
|
60 | /**
|
61 | * Create a listener for the `warning` event
|
62 | *
|
63 | * @param cb The callback function to run when the event is emitted
|
64 | */
|
65 | onWarning(cb: (warning: string) => Promise<void>): void;
|
66 | /**
|
67 | * Create a new listener for a given event
|
68 | *
|
69 | * @param eventName The name of the event that is being listened for
|
70 | * @param cb The callback function to run when the event is emitted
|
71 | */
|
72 | on<T = AnyJson>(eventName: string, cb: (data: T) => Promise<void>): void;
|
73 | /**
|
74 | * Emit a `telemetry` event, causing all callback functions to be run in the order they were registered
|
75 | *
|
76 | * @param data The data to emit
|
77 | */
|
78 | emitTelemetry(data: AnyJson): Promise<void>;
|
79 | /**
|
80 | * Emit a `warning` event, causing all callback functions to be run in the order they were registered
|
81 | *
|
82 | * @param data The warning (string) to emit
|
83 | */
|
84 | emitWarning(warning: string): Promise<void>;
|
85 | /**
|
86 | * Emit a given event, causing all callback functions to be run in the order they were registered
|
87 | *
|
88 | * @param eventName The name of the event to emit
|
89 | * @param data The argument to be passed to the callback function
|
90 | */
|
91 | emit<T = AnyJson>(eventName: string, data: T): Promise<void>;
|
92 | }
|
93 | export {};
|