UNPKG

launchdarkly-vue-client-sdk

Version:
75 lines (74 loc) 3.04 kB
import { LDClient, LDContext, LDOptions } from 'launchdarkly-js-client-sdk'; import { InjectionKey, Ref, App } from 'vue'; import { FlagRef } from './getLDFlag'; export { useLDReady, useLDFlag, ldInit, useLDClient } from './hooks'; export type { LDClient, LDContext, LDOptions, }; export type LDPluginOptions = { /** * Indicates which LaunchDarkly project to use. Must be provided here or in a call to {@link ldInit} for the SDK to work. */ clientSideID?: string | undefined; /** * A LaunchDarkly context object. If unspecified, an anonymous context * with kind: 'user' will be created and used. */ context?: LDContext; /** * @deprecated The `user` property will be removed in a future version, * please update your code to use context instead. */ user?: LDContext; /** * 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 for live updates to flags referenced using {@link useLDFlag}. * * Note that if `streaming` is provided in `options`, it will take precedence. * * @defaultValue `undefined` */ streaming?: boolean; /** * Defers initialization of the LaunchDarkly client until {@link ldInit} is called explicitly. * * @defaultValue `false` */ deferInitialization?: boolean; /** * Options to pass to the underlying javascript SDK. */ options?: LDOptions | undefined; }; /** * Injection key used to retreive LaunchDarkly client initialization function. Usage: `const ldInit = inject(LD_INIT)`. * Alternatively use {@link ldInit}. */ export declare const LD_INIT: InjectionKey<(o?: LDPluginOptions) => [Readonly<Ref<boolean>>, LDClient]>; /** * Injection key used to retrieve a boolean ref indicating if the LaunchDarkly client has finished initializing. * Usage: `const ldReady = inject(LD_READY)`. * Alternatively use {@link useLDReady}. */ export declare const LD_READY: InjectionKey<Readonly<Ref<boolean>>>; /** * Injection key used to retrieve LaunchDarkly client. Usage: `const ldClient = inject(LD_CLIENT)`. * Alternatively use {@link useLDClient}. */ export declare const LD_CLIENT: InjectionKey<LDClient>; /** * Injection key used to retrieve `ldFlag` function. Usage: `const ldFlag = inject(LD_FLAG)`. * Alternatively use {@link useLDFlag}. */ export declare const LD_FLAG: InjectionKey<(<T>(flagKey: string, defaultFlagValue?: T | undefined) => FlagRef<T>)>; /** * Vue plugin wrapper for the LaunchDarkly JavaScript SDK. * * If provided with a clientSideID will initialize the LaunchDarkly client automatically (unless `deferInitialization` is true). * * @see LDPluginOptions for configuration options */ export declare const LDPlugin: { install(app: App, pluginOptions?: LDPluginOptions): void; };