Options
All
  • Public
  • Public/Protected
  • All
Menu

Common interface for data sets and data view.

Type Parameters

  • Item extends PartItem<IdProp>

    Item type that may or may not have an id (missing ids will be generated upon insertion).

  • IdProp extends string = "id"

    Name of the property on the Item type that contains the id.

Hierarchy

  • DataInterface

Implemented by

Index

Properties

idProp: IdProp

The key of id property.

length: number

The number of items.

Methods

  • forEach(callback: ((item: Item, id: Id) => void), options?: DataInterfaceForEachOptions<Item>): void
  • Execute a callback function for each item.

    remarks

    No guarantee is given about the order of iteration unless an ordering function is supplied.

    Parameters

    • callback: ((item: Item, id: Id) => void)

      Executed in similar fashion to Array.forEach callback, but instead of item, index, array receives item, id.

        • (item: Item, id: Id): void
        • Parameters

          • item: Item
          • id: Id

          Returns void

    • Optional options: DataInterfaceForEachOptions<Item>

      Options to specify iteration details.

    Returns void

  • Get all the items.

    Returns FullItem<Item, IdProp>[]

    An array containing all the items.

  • Get all the items.

    Parameters

    Returns FullItem<Item, IdProp>[]

    An array containing requested items.

  • Get all the items.

    Parameters

    Returns Record<Id, FullItem<Item, IdProp>>

    An object map of items (may be an empty object if there are no items).

  • Get all the items.

    Parameters

    Returns FullItem<Item, IdProp>[] | Record<Id, FullItem<Item, IdProp>>

    An array containing requested items or if requested an object map of items (may be an empty object if there are no items).

  • Get one item.

    Parameters

    • id: Id

      The id of the item.

    Returns null | FullItem<Item, IdProp>

    The item or null if the id doesn't correspond to any item.

  • Get one item.

    Parameters

    Returns null | FullItem<Item, IdProp>

    The item or null if the id doesn't correspond to any item.

  • Get one item.

    Parameters

    Returns Record<Id, FullItem<Item, IdProp>>

    An object map of items (may be an empty object if no item was found).

  • Get one item.

    Parameters

    Returns null | FullItem<Item, IdProp> | Record<Id, FullItem<Item, IdProp>>

    The item if found or null otherwise. If requested an object map with 0 to 1 items.

  • Get multiple items.

    Parameters

    • ids: Id[]

      An array of requested ids.

    Returns FullItem<Item, IdProp>[]

    An array of found items (ids that do not correspond to any item are omitted).

  • Get multiple items.

    Parameters

    Returns FullItem<Item, IdProp>[]

    An array of found items (ids that do not correspond to any item are omitted).

  • Get multiple items.

    Parameters

    Returns Record<Id, FullItem<Item, IdProp>>

    An object map of items (may be an empty object if no item was found).

  • Get multiple items.

    Parameters

    Returns FullItem<Item, IdProp>[] | Record<Id, FullItem<Item, IdProp>>

    An array of found items (ids that do not correspond to any item are omitted). If requested an object map of items (may be an empty object if no item was found).

  • Get items.

    Parameters

    • ids: Id | Id[]

      Id or ids to be returned.

    • Optional options: DataInterfaceGetOptions<Item>

      Options to specify iteration details.

    Returns null | FullItem<Item, IdProp> | FullItem<Item, IdProp>[] | Record<Id, FullItem<Item, IdProp>>

    The items (format is determined by ids (single or array) and the options.

  • getDataSet(): DataSet<Item, IdProp>
  • Get the DataSet to which the instance implementing this interface is connected. In case there is a chain of multiple DataViews, the root DataSet of this chain is returned.

    Returns DataSet<Item, IdProp>

    The data set that actually contains the data.

  • Get ids of items.

    remarks

    No guarantee is given about the order of returned ids unless an ordering function is supplied.

    Parameters

    Returns Id[]

    An array of requested ids.

  • Map each item into different item and return them as an array.

    remarks

    No guarantee is given about the order of iteration even if ordering function is supplied (the items are sorted after the mapping).

    Type Parameters

    • T

    Parameters

    • callback: ((item: Item, id: Id) => T)

      Array.map-like callback, but only with the first two params.

        • (item: Item, id: Id): T
        • Parameters

          • item: Item
          • id: Id

          Returns T

    • Optional options: DataInterfaceMapOptions<Item, T>

      Options to specify iteration details.

    Returns T[]

    The mapped items.

  • off(event: "*", callback: (<N>(name: N, payload: EventPayloads<Item, IdProp>[N], senderId?: null | Id) => void)): void
  • off(event: "add", callback: ((name: "add", payload: null | AddEventPayload, senderId?: null | Id) => void)): void
  • off(event: "remove", callback: ((name: "remove", payload: null | RemoveEventPayload<Item, IdProp>, senderId?: null | Id) => void)): void
  • off(event: "update", callback: ((name: "update", payload: null | UpdateEventPayload<Item, IdProp>, senderId?: null | Id) => void)): void
  • Remove a universal event listener.

    Parameters

    • event: "*"

      Event name.

    • callback: (<N>(name: N, payload: EventPayloads<Item, IdProp>[N], senderId?: null | Id) => void)

      Callback function.

        • <N>(name: N, payload: EventPayloads<Item, IdProp>[N], senderId?: null | Id): void
        • Type Parameters

          Parameters

          • name: N

            The name of the event (EventName).

          • payload: EventPayloads<Item, IdProp>[N]

            Data about the items affected by this event.

          • Optional senderId: null | Id

            A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null.

          Returns void

    Returns void

  • Remove an add event listener.

    Parameters

    • event: "add"

      Event name.

    • callback: ((name: "add", payload: null | AddEventPayload, senderId?: null | Id) => void)

      Callback function.

        • (name: "add", payload: null | AddEventPayload, senderId?: null | Id): void
        • Parameters

          • name: "add"

            The name of the event (EventName).

          • payload: null | AddEventPayload

            Data about the items affected by this event.

          • Optional senderId: null | Id

            A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null.

          Returns void

    Returns void

  • Remove a remove event listener.

    Parameters

    • event: "remove"

      Event name.

    • callback: ((name: "remove", payload: null | RemoveEventPayload<Item, IdProp>, senderId?: null | Id) => void)

      Callback function.

        • (name: "remove", payload: null | RemoveEventPayload<Item, IdProp>, senderId?: null | Id): void
        • Parameters

          • name: "remove"

            The name of the event (EventName).

          • payload: null | RemoveEventPayload<Item, IdProp>

            Data about the items affected by this event.

          • Optional senderId: null | Id

            A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null.

          Returns void

    Returns void

  • Remove an update event listener.

    Parameters

    • event: "update"

      Event name.

    • callback: ((name: "update", payload: null | UpdateEventPayload<Item, IdProp>, senderId?: null | Id) => void)

      Callback function.

        • (name: "update", payload: null | UpdateEventPayload<Item, IdProp>, senderId?: null | Id): void
        • Parameters

          • name: "update"

            The name of the event (EventName).

          • payload: null | UpdateEventPayload<Item, IdProp>

            Data about the items affected by this event.

          • Optional senderId: null | Id

            A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null.

          Returns void

    Returns void

  • on(event: "*", callback: (<N>(name: N, payload: EventPayloads<Item, IdProp>[N], senderId?: null | Id) => void)): void
  • on(event: "add", callback: ((name: "add", payload: null | AddEventPayload, senderId?: null | Id) => void)): void
  • on(event: "remove", callback: ((name: "remove", payload: null | RemoveEventPayload<Item, IdProp>, senderId?: null | Id) => void)): void
  • on(event: "update", callback: ((name: "update", payload: null | UpdateEventPayload<Item, IdProp>, senderId?: null | Id) => void)): void
  • Add a universal event listener.

    remarks

    The * event is triggered when any of the events add, update, and remove occurs.

    Parameters

    • event: "*"

      Event name.

    • callback: (<N>(name: N, payload: EventPayloads<Item, IdProp>[N], senderId?: null | Id) => void)

      Callback function.

        • <N>(name: N, payload: EventPayloads<Item, IdProp>[N], senderId?: null | Id): void
        • Type Parameters

          Parameters

          • name: N

            The name of the event (EventName).

          • payload: EventPayloads<Item, IdProp>[N]

            Data about the items affected by this event.

          • Optional senderId: null | Id

            A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null.

          Returns void

    Returns void

  • Add an add event listener.

    remarks

    The add event is triggered when an item or a set of items is added, or when an item is updated while not yet existing.

    Parameters

    • event: "add"

      Event name.

    • callback: ((name: "add", payload: null | AddEventPayload, senderId?: null | Id) => void)

      Callback function.

        • (name: "add", payload: null | AddEventPayload, senderId?: null | Id): void
        • Parameters

          • name: "add"

            The name of the event (EventName).

          • payload: null | AddEventPayload

            Data about the items affected by this event.

          • Optional senderId: null | Id

            A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null.

          Returns void

    Returns void

  • Add a remove event listener.

    remarks

    The remove event is triggered when an item or a set of items is removed.

    Parameters

    • event: "remove"

      Event name.

    • callback: ((name: "remove", payload: null | RemoveEventPayload<Item, IdProp>, senderId?: null | Id) => void)

      Callback function.

        • (name: "remove", payload: null | RemoveEventPayload<Item, IdProp>, senderId?: null | Id): void
        • Parameters

          • name: "remove"

            The name of the event (EventName).

          • payload: null | RemoveEventPayload<Item, IdProp>

            Data about the items affected by this event.

          • Optional senderId: null | Id

            A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null.

          Returns void

    Returns void

  • Add an update event listener.

    remarks

    The update event is triggered when an existing item or a set of existing items is updated.

    Parameters

    • event: "update"

      Event name.

    • callback: ((name: "update", payload: null | UpdateEventPayload<Item, IdProp>, senderId?: null | Id) => void)

      Callback function.

        • (name: "update", payload: null | UpdateEventPayload<Item, IdProp>, senderId?: null | Id): void
        • Parameters

          • name: "update"

            The name of the event (EventName).

          • payload: null | UpdateEventPayload<Item, IdProp>

            Data about the items affected by this event.

          • Optional senderId: null | Id

            A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null.

          Returns void

    Returns void

  • Stream.

    Parameters

    • Optional ids: Iterable<Id>

      Ids of the items to be included in this stream (missing are ignored), all if omitted.

    Returns DataStream<Item>

    The data stream for this data set.

Generated using TypeDoc