Class AsyncWritableInMemoryStore<ItemType, IDType>

A writeable asynchronous store.

Type Parameters

  • ItemType extends Record<string, any>
  • IDType extends string | number

Hierarchy (view full)

Implements

Properties

on: undefined | {
    <Name>(eventName: Name, callback: EventCallback<StoreEvents<IDType>[Name]>): EventHandle;
    (eventName: "*", callback: EventCallback<StoreChangedEvent<IDType>>): EventHandle;
    (eventName: string | string[], callback: EventCallback<unknown>): EventHandle;
}

Register event listener for specific events.

Type declaration

    • <Name>(eventName, callback): EventHandle
    • Type Parameters

      • Name extends "changed"

      Parameters

      Returns EventHandle

    • (eventName, callback): EventHandle
    • Register event listener for any event.

      Parameters

      • eventName: "*"

        must be "*" for this overload

      • callback: EventCallback<StoreChangedEvent<IDType>>

        the event handler callback will be invoked when any event has been emitted

      Returns EventHandle

      a handle to unregister from the events

    • (eventName, callback): EventHandle
    • Register event listener for the events listed in eventName. Comma separated event names are possible, for example "eventA,eventB".

      Parameters

      • eventName: string | string[]

        the event name or list of names

      • callback: EventCallback<unknown>

        the event handler callback

      Returns EventHandle

      a handle to unregister from the event(s)

name of the event

the event handler callback will be invoked when the event has been emitted

a handle to unregister from the event

Accessors

  • get id(): undefined | string
  • ID of the store.

    Returns undefined | string

  • get idProperty(): undefined | string
  • Name of the property used as ID. If not provided, the 'getIdentity' method must be declared.

    Returns undefined | string

Methods

  • Create a new item. Throws an error, if the item already exists. The 'overwrite' option is assumed to be false).

    Parameters

    Returns Promise<void | ItemType>

  • Saves the given item. Depending on the specified options, a new item is created or a given item is updated.

    Parameters

    Returns Promise<void | ItemType>

  • Delete an item by id.

    Parameters

    • id: IDType

      id of item to delete

    Returns Promise<void>