Handle fetching and saving user specific data, e.g. settings or other state data that should persist between sessions

Hierarchy

Methods

Methods

  • Get user data

    Returns

    the data

    Type Parameters

    • T = any

    Parameters

    • key: string

      name of the key containing the data

    Returns T

  • Check if user data exists

    Returns

    true if user data exists

    Parameters

    • key: string

      name of the key containing the data

    Returns boolean

  • Set user data

    Returns

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

    Type Parameters

    • T = any

    Parameters

    • key: string

      name of the key for the data

    • Optional data: T

      the data to save, will delete the data if undefined

    Returns Promise<void>

  • Subscribe to state changes

    Returns

    unsubscribe callback

    Parameters

    • callback: ((...args: unknown[]) => void)

      function to call when subscription updates

        • (...args: unknown[]): void
        • Parameters

          • Rest ...args: unknown[]

          Returns void

    • Optional options: StateOptions

      options for the state selector

    Returns (() => void)

      • (): void
      • Subscribe to state changes

        Returns

        unsubscribe callback

        Returns void