#
InMemoryLaunchDarklyClient
An in-memory implementation of the LaunchDarkly SDK client.
#
Reference
const client = new InMemoryLaunchDarklyClient(featureFlags, options?: { context?, notifier? })
#
Parameters
featureFlags: A map instance of feature flags.options: An optional object literal of options:context: A LaunchDarkly SDK context.notifier: ALaunchDarklyClientNotifierinstance.
#
Methods
- Implements all the base methods of the LaunchDarkly SDK client.
setFeatureFlags: Update feature flags values.
#
Usage
#
Create an instance
import { InMemoryLaunchDarklyClient } from "@squide/firefly";
const featureFlags = {
"show-characters": true
};
const client = new InMemoryLaunchDarklyClient(featureFlags);
#
Provide a context
By default client context is { kind: "user", anonymous: true }. To customize the context, provide a context option.
import { InMemoryLaunchDarklyClient } from "@squide/firefly";
const featureFlags = {
"show-characters": true
};
const client = new InMemoryLaunchDarklyClient(featureFlags, {
context: {
kind: "multi",
user: {
key: "user-123",
name: "Sandy",
email: "sandy@example.com"
},
org: {
key: "org-456",
name: "Acme Inc",
plan: "enterprise"
}
}
});
#
Update flags value
import { InMemoryLaunchDarklyClient } from "@squide/firefly";
const featureFlags = {
"show-characters": true,
"render-summary": true
};
const client = new InMemoryLaunchDarklyClient(featureFlags);
client.setFeatureFlags({
"show-characters": true,
"render-summary": false
});