The default concrete implementation of a state database.

Type Parameters

  • T extends ReadonlyPartialJSONValue = ReadonlyPartialJSONValue

Implements

Constructors

Properties

_changed: Signal<StateDB<T>, Change> = ...
_connector: IDataConnector<string, string, string, string>
_ready: Promise<void>

Accessors

Methods

  • Retrieve a saved bundle from the database.

    Parameters

    • id: string

      The identifier used to retrieve a data bundle.

    Returns Promise<undefined | T>

    A promise that bears a data payload if available.

    Notes

    The id values of stored items in the state database are formatted: 'namespace:identifier', which is the same convention that command identifiers in JupyterLab use as well. While this is not a technical requirement for fetch(), remove(), and save(), it is necessary for using the list(namespace: string) method.

    The promise returned by this method may be rejected if an error occurs in retrieving the data. Non-existence of an id will succeed with the value undefined.

  • Retrieve all the saved bundles for a namespace.

    Parameters

    • namespace: string

      The namespace prefix to retrieve.

    Returns Promise<{
        ids: string[];
        values: T[];
    }>

    A promise that bears a collection of payloads for a namespace.

    Notes

    Namespaces are entirely conventional entities. The id values of stored items in the state database are formatted: 'namespace:identifier', which is the same convention that command identifiers in JupyterLab use as well.

    If there are any errors in retrieving the data, they will be logged to the console in order to optimistically return any extant data without failing. This promise will always succeed.

  • Save a value in the database.

    Parameters

    • id: string

      The identifier for the data being saved.

    • value: T

      The data being saved.

    Returns Promise<void>

    A promise that is rejected if saving fails and succeeds otherwise.

    Notes

    The id values of stored items in the state database are formatted: 'namespace:identifier', which is the same convention that command identifiers in JupyterLab use as well. While this is not a technical requirement for fetch(), remove(), and save(), it is necessary for using the list(namespace: string) method.