@launchdarkly/js-client-sdk-common - v1.35.0
    Preparing search index...

    Interface LDStorage

    Interface for providing a custom storage implementation to a client-side SDK.

    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.

    Storage is used to cache flag values per context and to persist generated identifiers. It may be used for additional features in the future.

    Implementations should not throw exceptions. If an implementation does throw, the SDK guards against it: the error is logged and the operation degrades gracefully (reads return null, writes are dropped) rather than crashing the host application.

    interface LDStorage {
        clear: (key: string) => Promise<void>;
        get: (key: string) => Promise<string | null>;
        set: (key: string, value: string) => Promise<void>;
    }
    Index
    clear: (key: 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.

    Type Declaration

      • (key: string): Promise<void>
      • Parameters

        • key: string

          The key to clear the value for.

        Returns Promise<void>

        A promise that resolves after that operation completes.

    get: (key: string) => Promise<string | null>

    Get a value from the storage.

    Type Declaration

      • (key: string): Promise<string | null>
      • Parameters

        • key: string

          The key to get a value for.

        Returns Promise<string | null>

        A promise which resolves to the value for the specified key, or null if there is no value for the key.

    set: (key: string, value: string) => Promise<void>

    Set the given key to the specified value.

    Type Declaration

      • (key: string, value: string): Promise<void>
      • Parameters

        • key: string

          The key to set a value for.

        • value: string

          The value to set for the key.

        Returns Promise<void>

        A promise that resolves after the operation completes.