@dxos/echo-react
    Preparing search index...

    Function usePagination

    • Wraps a query with page management for paginated reads. The query's own .limit(n) clause is the page size -- the hook manages which page is loaded by rewriting skip/limit on top of it; the query must not carry its own .skip().

      The query's .orderBy(...) is otherwise untouched, and applies to any query the underlying Database.Queryable supports -- e.g. Order.natural('desc') for feed insertion order.

      Keeps showing the previous page while a new one loads -- across both a skip/limit move and a query-identity change (filter/order/page-size/resource). The latter rebuilds the internal store; the last page is handed to the new store as its seed so the view refreshes in place instead of flashing empty, and isLoading stays put (a background refresh isn't a load the user asked for).

      Type Parameters

      • Q extends Any

      Parameters

      Returns PaginationResult<PaginationElement<Q>>

      const { items, getNext, hasMore, isLoading, atHead, jumpToHead } = usePagination(
      db,
      Query.select(Filter.type(Message.Message)).from(feed).orderBy(Order.natural('desc')).limit(50),
      );