@launchdarkly/react-native-client-sdk
Version:
React Native LaunchDarkly SDK
140 lines • 5.41 kB
TypeScript
import { ConnectionMode, LDClientDataSystemOptions, LDOptions } from '@launchdarkly/js-client-sdk-common';
import { LDPlugin } from './LDPlugin';
/**
* Interface for providing custom storage implementations for react Native.
*
* This interface should only be used when customizing the storage mechanism
* used by the SDK. Typical usage of the SDK does not require implementing
* this interface.
*
* Implementations may not throw exceptions.
*
* The SDK assumes that the persistence is only being used by a single instance
* of the SDK per SDK key (two different SDK instances, with 2 different SDK
* keys could use the same persistence instance).
*
* The SDK, with correct usage, will not have overlapping writes to the same
* key.
*
* This interface does not depend on the ability to list the contents of the
* store or namespaces. This is to maintain the simplicity of implementing a
* key-value store on many platforms.
*/
export interface RNStorage {
/**
* Implementation Note: This is the same as the platform storage interface.
* The implementation is duplicated to avoid exposing the internal platform
* details from implementors. This allows for us to modify the internal
* interface without breaking external implementations.
*/
/**
* Get a value from the storage.
*
* @param key The key to get a value for.
* @returns A promise which resolves to the value for the specified key, or
* null if there is no value for the key.
*/
get: (key: string) => Promise<string | null>;
/**
* Set the given key to the specified value.
*
* @param key The key to set a value for.
* @param value The value to set for the key.
* @returns A promise that resolves after the operation completes.
*/
set: (key: string, value: string) => Promise<void>;
/**
* Clear the value associated with a given key.
*
* After clearing a key subsequent calls to the get function should return
* null for that key.
*
* @param key The key to clear the value for.
* @returns A promise that resolves after that operation completes.
*/
clear: (key: string) => Promise<void>;
}
/**
* Data system options for the React Native SDK.
*
* Note: Network-based automatic mode switching is not yet supported.
* Lifecycle-based switching is.
*
* This interface 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
*/
export interface RNDataSystemOptions extends LDClientDataSystemOptions {
}
export interface RNSpecificOptions {
/**
* Some platforms (windows, web, mac, linux) can continue executing code
* in the background.
*
* Defaults to false.
*/
readonly runInBackground?: boolean;
/**
* Enable handling of network availability. When this is true the
* connection state will automatically change when network
* availability changes.
*
* Defaults to true.
*/
readonly automaticNetworkHandling?: boolean;
/**
* Enable handling associated with transitioning between the foreground
* and background.
*
* Defaults to true.
*/
readonly automaticBackgroundHandling?: boolean;
/**
* Custom storage implementation.
*
* Typical SDK usage will not involve using customized storage.
*
* Storage is used used for caching flag values for context as well as persisting generated
* identifiers. Storage could be used for additional features in the future.
*
* Defaults to `@react-native-async-storage/async-storage` see [their documentation](https://react-native-async-storage.github.io/2.0/) for more information.
*
* @remarks
* If there is an issue with the storage implementation, then generated keys and context caches may not be persisted. This will cause the SDK to
* generate new keys and context caches on every startup.
*/
readonly storage?: RNStorage;
/**
* Sets the mode to use for connections when the SDK is initialized.
*
* @remarks
* Possible values are offline, streaming, or polling. See {@link ConnectionMode} for more information.
*
* @defaultValue streaming.
*/
initialConnectionMode?: ConnectionMode;
/**
* A list of plugins to be used with the SDK.
*
* Plugin support is currently experimental and subject to change.
*/
plugins?: LDPlugin[];
/**
* Configuration for the FDv2 data system. When present, the SDK uses
* the FDv2 protocol for flag delivery instead of the default FDv1
* protocol.
*
* Note: Network-based automatic mode switching is not yet supported.
* Lifecycle-based switching (foreground/background) is fully functional.
*
* This option 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
*/
dataSystem?: RNDataSystemOptions;
}
export default interface RNOptions extends LDOptions, RNSpecificOptions {
}
//# sourceMappingURL=RNOptions.d.ts.map