Handle fetching and saving user preferences.

Hierarchy

  • UserPreferencesRepository

Methods

Methods

  • Get the current user preferences.

    Returns

    If a key is supplied, the value stored under that key is returned. If no key is supplied, an object with all preferences is returned instead.

    Type Parameters

    • T = any

    Parameters

    • Optional key: string

      Supply the key for a specific preference to get only that value.

    Returns T

  • Get the schema for the user preferences.

    Returns Record<string, unknown>

  • Set or delete the value for a specific user preference.

    Note

    The value set must be serializable as JSON. If non-serializable data is given, it might result in an error, but more likely, the data will simply be lost.

    Returns

    a promise that will be resolved when the data has been saved

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key to store the value under.

    • Optional data: T

      The data to save. Leave undefined to instead delete the currently stored value.

    Returns Promise<void>