A store whose calls settle later, as IndexedDB's do. The widget reads a namespace from it once (entries) and answers every later read from that copy, so its own reads stay synchronous; writes follow behind. Having an entries method is what marks a store as asynchronous.

interface AsyncStorageLike {
    journal?: null | StorageLike;
    entries(prefix: string): Promise<readonly (readonly [string, string])[]>;
    removeItem(key: string): Promise<void>;
    setItem(key: string, value: string): Promise<void>;
    subscribe(
        listener: (key: string, value: null | string) => void,
    ): () => void;
}

Hierarchy (View Summary)

Properties

journal?: null | StorageLike

A synchronous store the writes still pending are copied to when the page goes away, and read back by the next load, because an asynchronous write started as a page closes may never land. Without one, those writes are lost with the page.

Methods

  • Every stored key that starts with prefix, with its value.

    Parameters

    • prefix: string

    Returns Promise<readonly (readonly [string, string])[]>

  • Hear each change other users of the store make once it has landed: another tab on the same database, or another widget on the page. The widget keeps its copy of the namespace current with it, as a synchronous store's reads are, so an instrument whose drawings another tab changed opens with them rather than overwriting them with an older copy. A null value is a removal. Returns the call that stops listening. Without it, the copy knows only what it read at load and what it wrote itself.

    Parameters

    • listener: (key: string, value: null | string) => void

    Returns () => void