Provides a TJSWebStorage instance for standard browser session storage use cases.

Hierarchy (view full)

Constructors

Methods

  • Get value from the storage API.

    Parameters

    • key: string

      Key to lookup in storage API.

    • Optional defaultValue: any

      A default value to return if key not present in session storage.

    Returns any

    Value from session storage or if not defined any default value provided.

  • Returns the backing Svelte store for the given key; potentially sets a default value if the key is not already set.

    Type Parameters

    • T

    Parameters

    • key: string

      Key to lookup in storage API.

    • Optional defaultValue: T

      A default value to return if key not present in session storage.

    • Optional storageStores: StorageStores

      Additional store creation options.

    Returns Writable<T>

    The Svelte store for this key.

  • Sets the value for the given key in storage API.

    Parameters

    • key: string

      Key to lookup in storage API.

    • value: any

      A value to set for this key.

    Returns void

  • Convenience method to swap a boolean value stored in storage API.

    Parameters

    • key: string

      Key to lookup in storage API.

    • Optional defaultValue: boolean

      A default value to return if key not present in session storage.

    Returns boolean

    The boolean swap for the given key.