LDClient: Omit<CommonClient, "getConnectionMode" | "getOffline" | "identify"> & {
    setConnectionMode(mode?) => void;
    setStreaming(streaming?) => void;
    start(options?) => Promise<LDWaitForInitializationResult>;
    waitForInitialization(options?) => Promise<LDWaitForInitializationResult>;
}

The LaunchDarkly SDK client object.

Applications should configure the client at page load time and reuse the same instance.

For more information, see the SDK Reference Guide.

Type declaration

  • setConnectionMode:function
    • Sets the connection mode for the SDK's data system.

      When set, this mode is used exclusively, overriding all automatic mode selection (including setStreaming). The setStreaming state is not modified -- setConnectionMode acts as a higher-priority override.

      Pass undefined (or call with no arguments) to clear the override and return to automatic mode selection.

      This method requires the FDv2 data system (dataSystem option). If FDv2 is not enabled, the call logs a warning and has no effect.

      This method is not stable, and not subject to any backwards compatibility guarantees or semantic versioning. It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode

      Parameters

      • Optional mode: FDv2ConnectionMode

        The connection mode to use, or undefined to clear the override.

        Optional

      Returns void

  • setStreaming:function
    • Specifies whether or not to open a streaming connection to LaunchDarkly for live flag updates.

      If this is true, the client will always attempt to maintain a streaming connection; if false, it never will. If you leave the value undefined (the default), the client will open a streaming connection if you subscribe to "change" or "change:flag-key" events (see LDClient.on).

      This can also be set as the streaming property of LDOptions.

      Parameters

      • Optional streaming: boolean
        Optional

      Returns void

  • start:function
  • waitForInitialization:function
    • Returns a Promise that tracks the client's initialization state.

      The Promise will be resolved to a LDWaitForInitializationResult object containing the status of the waitForInitialization operation.

      Parameters

      Returns Promise<LDWaitForInitializationResult>

      A Promise that will be resolved to a LDWaitForInitializationResult object containing the status of the waitForInitialization operation.

      Example

      This example shows use of async/await syntax for specifying handlers:

          const result = await client.waitForInitialization({ timeout: 5 });

      if (result.status === 'complete') {
      doSomethingWithSuccessfullyInitializedClient();
      } else if (result.status === 'failed') {
      doSomethingForFailedStartup(result.error);
      } else if (result.status === 'timeout') {
      doSomethingForTimedOutStartup();
      }

      Remarks

      You can also use event listeners (on) for the same purpose: the event "initialized" indicates success, and "error" indicates an error.

Generated using TypeDoc