sej
    Preparing search index...

    Class AbstractStorage<T>

    AbstractStorage is a generic class that provides an interface for storing and retrieving data using IndexedDB through the localForage library. It includes methods for synchronous and asynchronous data retrieval and storage, as well as a method for clearing the storage.

    Type Parameters

    • T = StorageData

      The type of data to be stored and retrieved. Defaults to any.

    Implements

    Index

    Constructors

    Properties

    Methods

    Constructors

    • Initializes a new instance of the Storage class.

      This constructor checks if IndexedDB is supported in the current environment. If not, it throws an error. If supported, it creates a localforage instance with the specified configuration for the SEJ Editor.

      Type Parameters

      • T = any

      Returns AbstractStorage<T>

      If IndexedDB is not supported.

    Properties

    debug: boolean = false

    Whether debugging is enabled.

    false
    
    key: string = 'state'

    Key for the storage.

    'state'
    
    store: LocalForage

    LocalForage instance for the storage.

    version: number = 1

    Version of the storage.

    1
    

    Methods

    • Clears all items from the storage.

      This method removes all key-value pairs from the storage, effectively resetting it to an empty state.

      Returns void

    • Retrieves data from the storage and optionally executes a callback with the retrieved data.

      Parameters

      • Optionalcallback: (data: T) => void

        An optional callback function that will be called with the retrieved data.

      Returns void

      This method measures the time taken to load the state from IndexedDB and logs it if debugging is enabled.

    • Retrieves an item from the storage asynchronously.

      Returns Promise<null | T>

      A promise that resolves to the item retrieved from the storage, or null if the item does not exist.

    • Stores the provided data in IndexedDB and optionally executes a callback function.

      Parameters

      • data: T

        The data to be stored.

      • Optionalcallback: () => void

        An optional callback function to be executed after the data is stored.

      Returns void

    • Asynchronously sets the provided data in the storage.

      Parameters

      • data: T

        The data to be stored.

      Returns Promise<void>

      A promise that resolves when the data has been stored.

      This method measures the time taken to store the data and logs it to the console if debugging is enabled.