launchdarkly-react-client-sdk
Version:
LaunchDarkly SDK for React
56 lines (55 loc) • 2.58 kB
TypeScript
import { LDClient, LDContext, LDFlagChangeset, LDFlagSet } from 'launchdarkly-js-client-sdk';
import { ProviderConfig } from './types';
/**
* Helper function to get the context or fallback to classic user.
* Safe to remove when the user property is deprecated.
*/
export declare const getContextOrUser: (config: ProviderConfig) => LDContext | undefined;
/**
* Transforms a set of flags so that their keys are camelCased. This function ignores
* flag keys which start with `$`.
*
* @param rawFlags A mapping of flag keys and their values
* @return A transformed `LDFlagSet` with camelCased flag keys
*/
export declare const camelCaseKeys: {
(rawFlags: LDFlagSet): LDFlagSet;
/**
* @deprecated The `camelCaseKeys.camelCaseKeys` property will be removed in a future version,
* please update your code to use the `camelCaseKeys` function directly.
*/
camelCaseKeys: /*elided*/ any;
};
/**
* Gets the flags to pass to the provider from the changeset.
*
* @param changes the `LDFlagChangeset` from the ldClient onchange handler.
* @param targetFlags if targetFlags are specified, changes to other flags are ignored and not returned in the
* flattened `LDFlagSet`
* @return an `LDFlagSet` with the current flag values from the LDFlagChangeset filtered by `targetFlags`. The returned
* object may be empty `{}` if none of the targetFlags were changed.
*/
export declare const getFlattenedFlagsFromChangeset: (changes: LDFlagChangeset, targetFlags: LDFlagSet | undefined) => LDFlagSet;
/**
* Retrieves flag values.
*
* @param ldClient LaunchDarkly client
* @param targetFlags If specified, `launchdarkly-react-client-sdk` will only listen for changes to these flags.
* Flag keys must be in their original form as known to LaunchDarkly rather than in their camel-cased form.
*
* @returns an `LDFlagSet` with the current flag values from LaunchDarkly filtered by `targetFlags`.
*/
export declare const fetchFlags: (ldClient: LDClient, targetFlags?: LDFlagSet) => LDFlagSet;
declare const _default: {
camelCaseKeys: {
(rawFlags: LDFlagSet): LDFlagSet;
/**
* @deprecated The `camelCaseKeys.camelCaseKeys` property will be removed in a future version,
* please update your code to use the `camelCaseKeys` function directly.
*/
camelCaseKeys: /*elided*/ any;
};
getFlattenedFlagsFromChangeset: (changes: LDFlagChangeset, targetFlags: LDFlagSet | undefined) => LDFlagSet;
fetchFlags: (ldClient: LDClient, targetFlags?: LDFlagSet) => LDFlagSet;
};
export default _default;