@mantlebee/ts-data
    Preparing search index...

    Function createLookupSource

    • A lookup source over a reader, the same QueryItemsReader a data source reads through: search asks for textField contains query (no filter when query is empty) with the pagination of the page, resolve asks for valueField in values without pagination (and does not call the reader for an empty list), valueOf reads valueField. The key type of the source is the type of valueField.

      Paging. Pagination is 1-based and page-based, so a page is { page: offset / limit + 1, itemsPerPage: limit, totalItemsCount: 0 } (the count is unknown): offset must be a multiple of limit, as it is when a panel always pages by its own limit; otherwise search rejects with a RangeError, without calling the reader. hasMore is items.length >= limit: no count reader, at the cost of one empty page when the total is a multiple of limit. Asking for one item more than limit would shift the next page, so it is not done.

      Signal. The signal is handed to the reader as it is (a fetch cancels the request), and the call rejects with AbortedException as soon as the signal is aborted, whatever the reader does with it: a reader ignoring the signal, like the in-memory one, still behaves.

      Type Parameters

      • TItem

        Type of the items, inferred from the reader.

      • TValueField extends string = KeyOf<TItem>

        Field holding the key, inferred from the options.

      Parameters

      Returns ILookupSource<TItem, TItem[TValueField]>

      a stateless source over the reader.

      const departments = createLookupSource(
      (payload, signal) => api.getDepartments(payload, { signal }),
      { textField: "name", valueField: "id" },
      ); // ILookupSource<Department, number>