@@ -11,6 +11,11 @@ import { BigSegmentStoreStatusProvider } from './interfaces';
1111 * and continue to use it throughout the lifetime of the application, rather than creating instances
1212 * on the fly.
1313 *
14+ * Note that `LDClient` inherits from `EventEmitter`, so you can use the standard `on()`, `once()`, and
15+ * `off()` methods to receive events. The standard `EventEmitter` methods are not documented here; see the
16+ * {@link https://nodejs.org/api/events.html#events_class_eventemitter|Node API documentation}. For a
17+ * description of events you can listen for, see {@link on}.
18+ *
1419 */
1520export interface LDClient extends LDClientCommon , EventEmitter {
1621 /**
@@ -21,4 +26,30 @@ export interface LDClient extends LDClientCommon, EventEmitter {
2126 * {@link interfaces.BigSegmentStoreStatusProvider} for more about this functionality.
2227 */
2328 readonly bigSegmentStoreStatusProvider : BigSegmentStoreStatusProvider ;
29+
30+ /**
31+ *
32+ * Registers an event listener that will be called when the client triggers some type of event.
33+ *
34+ * This is the standard `on` method inherited from Node's `EventEmitter`; see the
35+ * {@link https://nodejs.org/api/events.html#events_class_eventemitter|Node API docs} for more
36+ * details on how to manage event listeners. Here is a description of the event types defined
37+ * by `LDClient`.
38+ *
39+ * - `"ready"`: Sent only once, when the client has successfully connected to LaunchDarkly.
40+ * Alternately, you can detect this with [[waitForInitialization]].
41+ * - `"failed"`: Sent only once, if the client has permanently failed to connect to LaunchDarkly.
42+ * Alternately, you can detect this with [[waitForInitialization]].
43+ * - `"error"`: Contains an error object describing some abnormal condition that the client has detected
44+ * (such as a network error).
45+ * - `"update"`: The client has received a change to a feature flag. The event parameter is an object
46+ * containing a single property, `key`, the flag key. Note that this does not necessarily mean the flag's
47+ * value has changed for any particular context, only that some part of the flag configuration was changed.
48+ * - `"update:KEY"`: The client has received a change to the feature flag whose key is KEY. This is the
49+ * same as `"update"` but allows you to listen for a specific flag.
50+ *
51+ * @param event the name of the event to listen for
52+ * @param listener the function to call when the event happens
53+ */
54+ on ( event : string | symbol , listener : ( ...args : any [ ] ) => void ) : this;
2455}
0 commit comments