Skip to content

Commit

Permalink
chore: Add docs for emitted events. (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinyoklion authored Sep 11, 2023
1 parent aa0e3ae commit 0273c6c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/sdk/server-node/src/api/LDClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { BigSegmentStoreStatusProvider } from './interfaces';
* and continue to use it throughout the lifetime of the application, rather than creating instances
* on the fly.
*
* Note that `LDClient` inherits from `EventEmitter`, so you can use the standard `on()`, `once()`, and
* `off()` methods to receive events. The standard `EventEmitter` methods are not documented here; see the
* {@link https://nodejs.org/api/events.html#events_class_eventemitter|Node API documentation}. For a
* description of events you can listen for, see {@link on}.
*
*/
export interface LDClient extends LDClientCommon, EventEmitter {
/**
Expand All @@ -21,4 +26,30 @@ export interface LDClient extends LDClientCommon, EventEmitter {
* {@link interfaces.BigSegmentStoreStatusProvider} for more about this functionality.
*/
readonly bigSegmentStoreStatusProvider: BigSegmentStoreStatusProvider;

/**
*
* Registers an event listener that will be called when the client triggers some type of event.
*
* This is the standard `on` method inherited from Node's `EventEmitter`; see the
* {@link https://nodejs.org/api/events.html#events_class_eventemitter|Node API docs} for more
* details on how to manage event listeners. Here is a description of the event types defined
* by `LDClient`.
*
* - `"ready"`: Sent only once, when the client has successfully connected to LaunchDarkly.
* Alternately, you can detect this with [[waitForInitialization]].
* - `"failed"`: Sent only once, if the client has permanently failed to connect to LaunchDarkly.
* Alternately, you can detect this with [[waitForInitialization]].
* - `"error"`: Contains an error object describing some abnormal condition that the client has detected
* (such as a network error).
* - `"update"`: The client has received a change to a feature flag. The event parameter is an object
* containing a single property, `key`, the flag key. Note that this does not necessarily mean the flag's
* value has changed for any particular context, only that some part of the flag configuration was changed.
* - `"update:KEY"`: The client has received a change to the feature flag whose key is KEY. This is the
* same as `"update"` but allows you to listen for a specific flag.
*
* @param event the name of the event to listen for
* @param listener the function to call when the event happens
*/
on(event: string | symbol, listener: (...args: any[]) => void): this;
}

0 comments on commit 0273c6c

Please sign in to comment.