Creates an instance of the LaunchDarkly client.
The LaunchDarkly mobile key.
Enable / disable Auto environment attributes. When enabled, the SDK will automatically provide data about the mobile environment where the application is running. To learn more, read Automatic environment attributes. for more documentation.
LDOptions to initialize the client with.
Private Optional _connectionPrivate Optional _stateReadonly autoProtected dataProtected Optional Readonly dataProtected emitterProtected Readonly environmentProtected Optional initProtected Optional initialProtected Optional initializeProtected Optional initializedProtected Readonly isFDv2Readonly loggerReadonly platformReadonly sdkProtected Optional startGets the SDK connection mode.
Internal
Protected getProtected getIdentifies a context to LaunchDarkly. See LDClient.identify.
If used with the sheddable option set to true, then the identify operation will be sheddable. This means that if
multiple identify operations are done, without waiting for the previous one to complete, then intermediate
operations may be discarded.
It is recommended to use the identifyResult method instead when the operation is sheddable. In a future release,
all identify operations will default to being sheddable.
The LDContext object to be identified.
Optional identifyOptions: LDIdentifyOptionsOptional configuration. See LDIdentifyOptions.
Optional A Promise which resolves when the flag values for the specified context are available. It rejects when:
The context is unspecified or has no key.
The identify timeout is exceeded. In client SDKs this defaults to 5s. You can customize this timeout with identifyOptions.
A network error is encountered during initialization.
Identifies a context to LaunchDarkly and returns a promise which resolves to an object containing the result of the identify operation.
Unlike the server-side SDKs, the client-side JavaScript SDKs maintain a current context state,
which is set when you call identify().
Changing the current context also causes all feature flag values to be reloaded. Until that has finished, calls to variation will still return flag values for the previous context. You can await the Promise to determine when the new flag values are available.
If used with the sheddable option set to true, then the identify operation will be sheddable. This means that if
multiple identify operations are done, without waiting for the previous one to complete, then intermediate
operations may be discarded.
The LDContext object.
Optional identifyOptions: LDIdentifyOptionsOptional configuration. Please see LDIdentifyOptions.
Optional A promise which resolves to an object containing the result of the identify operation. The promise returned from this method will not be rejected.
Protected maybeSets the initialization result and resolves any pending waitForInitialization promises. This method is idempotent and will only be set by the initialization flow. Subsequent calls should not do anything.
The initialization result.
Rest ...args: any[]Rest Rest ...args: any[]Rest Protected presetPreset flags are used to set the flags before the client is initialized. This is useful for when client has precached flags that are ready to evaluate without full initialization.
The flags to preset.
Protected sendSets the SDK connection mode.
The connection mode to use ('streaming', 'polling', or 'offline').
Internal
This overload is experimental and should NOT be considered ready for production use. It may change or be removed without notice and is not subject to backwards compatibility guarantees.
Sets the connection mode for the FDv2 data system.
When the FDv2 data system is enabled (dataSystem option), this method
additionally accepts 'one-shot' and 'background' modes. Pass
undefined to clear an explicit override and return to automatic mode
selection.
Optional mode: FDv2ConnectionModeThe connection mode to use, or undefined to clear the
override (FDv2 only).
Optional Protected setStarts the client and returns a promise that resolves to the initialization result.
This method is idempotent - calling it multiple times returns the same promise.
Optional options: LDStartOptionsOptional configuration. See LDStartOptions.
Optional A promise that resolves to the initialization result.
Optional options: LDWaitForInitializationOptionsOptional Generated using TypeDoc
Interface that extends the LDClient interface to include the identifyResult method.
This is an independent interface for backwards compatibility. Adding this to the LDClient interface would require a breaking change.