Namespaced JSON storage that never throws: a private window, a full quota or a blocked store all read as "nothing saved" and write as "not kept".

Over a synchronous store every call goes straight through. Over an asynchronous one, get, set and remove work on a copy of the namespace in memory: load fills it once, and each change is sent behind it, the changes to one key made within one task coalesced into one write. A write made before load settles waits for it and wins over the stored value, because it is the newer of the two. A store that can say so (subscribe) keeps the copy current with the writes other tabs land, as a synchronous store's reads always were, until close.

Constructors

Accessors

Methods

Constructors

Accessors

  • get loaded(): boolean
  • Whether reads answer from what is stored: always over a synchronous store, once load has settled over an asynchronous one.

    Returns boolean

Methods

  • Stop following the changes other users of an asynchronous store make. Changes already taken are still sent. The widget calls it when it is destroyed; a copy nobody reads again need not follow the store.

    Returns void

  • Send every change made so far now, and settle once each has landed or failed. Before the sends it copies them to the store's journal, which is what makes it the call for a page going away. Never rejects.

    Returns Promise<void>

  • Read the namespace from an asynchronous store, once; later calls return the same promise. Settles at once over a synchronous store. Never rejects: a store that fails or does not answer within a few seconds is reported through onError, and the session then runs on memory.

    Returns Promise<void>

  • True when the write landed; over an asynchronous store, when it was taken to be sent.

    Parameters

    • name: string
    • value: unknown

    Returns boolean