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

    Type Alias QueryItemsReader<TItem, TResult>

    QueryItemsReader: (
        payload: QueryItemsPayload<TItem>,
        signal?: AbortSignal,
    ) => Promise<TResult>

    Function that resolves a QueryItemsPayload into a result: the items matching it, or anything else derived from it (e.g. the total count a pagination needs). A DataSource reads through one; the in-memory folder ships readers over a plain array.

    The optional signal is aborted when the read the reader serves is superseded by a newer one (or the data source is disposed): hand it to fetch to cancel the request, or ignore it, the data source discards the result of a superseded read anyway. Every reader written for the first parameter only keeps working.

    Type Parameters

    • TItem = Any

      Type of the items.

    • TResult = List<TItem>

      Type of the result, the list of items by default.

    Type Declaration

    const reader: QueryItemsReader<User> = (payload, signal) =>
    fetch("/users", { body: JSON.stringify(payload), method: "POST", signal }).then((a) => a.json());
    const countReader: QueryItemsReader<User, number> = (payload, signal) =>
    fetch("/users/count", { body: JSON.stringify(payload.filters), method: "POST", signal }).then((a) => a.json());