Class WappStorage<T>

Class representing a WappStorage instance.

Type Parameters

  • T extends Record<string, unknown> = Record<string, unknown>

    The type of the stored data.

Implements

Constructors

  • Initializes a WappStorage instance with the provided name.

    Type Parameters

    • T extends Record<string, unknown> = Record<string, unknown>

    Parameters

    • name: string

      The name of the WappStorage instance.

    Returns WappStorage<T>

Properties

id: string = ''
name: string = ''

Methods

  • Unregister the callback function that was previously registered with onChange.

    Returns Promise<boolean>

    A promise that resolves to true if the callback was successfully unregistered, and false otherwise.

  • Retrieves an iterator of all the key-value pairs in the storage.

    Type Parameters

    • K extends string | number | symbol

    Returns [K, T[K]][]

    An iterator of key-value pairs.

  • Retrieves the value associated with the given name.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • name: K

      The name of the value to retrieve.

    Returns undefined | T[K]

    The value associated with the given name.

  • Retrieves the value associated with the given name.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • name: K[]

      The name of the value to retrieve.

    Returns (undefined | T[K])[]

    The value associated with the given name.

  • Retrieves the secret value associated with the given name.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • name: K

      The name of the secret value to retrieve.

    Returns undefined | T[K]

    The secret value associated with the given name, or undefined if the value is not found.

  • Retrieves the secret value associated with the given name.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • name: K[]

      The name of the secret value to retrieve.

    Returns (undefined | T[K])[]

    The secret value associated with the given name, or undefined if the value is not found.

  • Initializes the WappStorage instance by fetching data based on the provided name.

    Returns Promise<void>

    A Promise that resolves once the initialization is complete.

  • Reloads the data from the server.

    Returns Promise<boolean>

    A promise that resolves to a boolean indicating whether the reload was successful.

  • Removes the specified name(s) from the storage.

    Parameters

    • name: string | string[]

      The name or an array of names to be removed.

    Returns Promise<boolean>

    A promise that resolves to true if the name(s) were successfully removed, and false otherwise.

  • Removes a secret value from the storage.

    Parameters

    • name: string | string[]

      The name of the secret value to remove, or an array of names.

    Returns Promise<boolean>

    A promise that resolves to true if the secret value was successfully removed, and false otherwise.

  • Resets the state of the wapp storage.

    Returns Promise<void>

    A promise that resolves when the reset is complete.

  • Sets the value of a key-value pair in the storage.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • name: T | K

      The name of the key or an object containing multiple key-value pairs.

    • Optionalitem: T[K]

      The value to set for the specified key. This parameter is optional when setting multiple key-value pairs.

    Returns Promise<boolean>

    A Promise that resolves to true if the value was successfully set, and false otherwise.

  • Sets the secret value of a key-value pair in the storage.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • name: T | K

      The name of the key or an object containing multiple key-value pairs.

    • Optionalitem: T[K]

      The value to set as a secret for the specified key. This parameter is optional when setting multiple key-value pairs.

    Returns Promise<boolean>

    A Promise that resolves to true if the secret value was successfully set, and false otherwise.

  • Updates the data and returns a promise that resolves to a boolean indicating whether the update was successful.

    Returns Promise<boolean>

    A promise that resolves to true if the update was successful, and false otherwise.