Helpful
    Preparing search index...

    Class ZDataSourceStatic<T>

    Represents an in memory data source.

    This is very useful for testing and when you need to cache a data set that you already have.

    Type Parameters

    • T

    Implements

    Index

    Constructors

    Methods

    • Retrieves the total count of data items before pagination.

      Parameters

      • request: IZDataRequest

        The data request being made. The page and size fields are ignored in this instance.

      Returns Promise<number>

      The total number of items across pages that the request data set will represent.

    • Inserts an item into the existing data array.

      Parameters

      • item: T

        The item to insert.

      • index: number = Infinity

        The index to insert at. If this is equal to or less than 0 Then the item will be inserted at the front of the data list. If this is greater than or equal to the maximum number of items in the current list, then the item will be inserted at the end of the list.

      Returns Promise<ZDataSourceStatic<T>>

      A new data source where the item list has been updated to include the new item.

    • Gets a copy of the current list of items.

      This is equivalent to invoking retrieve with the default data request.

      Returns Promise<T[]>

      A shallow copy of the current item list. Returns a rejected promise if the initial data is an error.

    • Removes a specific matched item in the list.

      Parameters

      • item: T

        The item to remove. This will be an exact match.

      Returns Promise<ZDataSourceStatic<T>>

      A new data source with the item removed, or a direct copy if no such item exists within the list. Returns a rejected promise if the original data is an error.

    • Removes a specific item at a given index.

      Parameters

      • index: number

        The index of the item to remove.

      Returns Promise<ZDataSourceStatic<T>>

      A new data source with the item at the given index removed, or a direct copy if the index is out of range. Returns a rejected promise if the original data is an Error.

    • Updates an item at the given index.

      Parameters

      • item: T

        The item to set.

      • index: number

        The index of the item to replace.

      Returns Promise<ZDataSourceStatic<T>>

      A new data source with the item at the given index updated, or a direct copy if the index is out of range. Returns a rejected promise if the original data is an Error.