# LaunchDarklyPlugin

A plugin to faciliate the usage of LaunchDarkly feature flags in a modular application.

# Reference

const plugin = new LaunchDarklyPlugin(runtime, launchDarklyClient, { options?: { featureFlagSetSnapshot? } })

# Parameters

  • runtime: A runtime instance.
  • launchDarklyClient: A LaunchDarkly SDK client instance that is ready.
  • options: An optional object literal of options:

# Usage

Before creating the plugin instance, initialize the LaunchDarkly client with streaming enabled, then wait until the client is ready.

import { FireflyRuntime, LaunchDarklyPlugin } from "@squide/firefly";
import { initialize as initializeLaunchDarkly } from "launchdarkly-js-client-sdk";

const launchDarklyClient = initializeLaunchDarkly("123", {
    kind: "user",
    anonymous: true
}, {
    // It's important to use the stream mode to receive feature flags
    // updates in real time.
    streaming: true
});

try {
    // Always initialize the client before creating the plugin instance.
    await launchDarklyClient.waitForInitialization(5);
} catch (error: unknown) {
    // Failed to initialize LaunchDarkly...
}

const runtime = new FireflyRuntime({
    plugins: [x => new LaunchDarklyPlugin(x, launchDarklyClient)]
});