/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** What a view reads its pages from ({@link usePageReads}). */ export interface PageReader { /** The collection the pages are of: when it changes the pages start afresh, and a page read for an earlier one lands nothing. */ readonly identity: string; /** * Reads a page. * * @param page - The page's index * @param live - Whether the read still lands: what a reader checks before it does anything beside answering the page * @returns What the page holds; or `undefined` for a page that lands nothing — its reader started the pages afresh, * say — which is read again when it is wanted */ read(page: number, live: () => boolean): Promise; /** The most pages held: those far from what the view shows go past it. */ readonly retain: number; } /** A collection's pages, as a view reads them ({@link usePageReads}). */ export interface PageReads { /** The pages that landed, by index. */ readonly pages: ReadonlyMap; /** How many pages are being read. */ readonly loading: number; /** Why the first page that could not be read could not be; `undefined` while every one could. */ readonly failure: Error | undefined; /** * Reads the pages `[first, last]` that have not landed and are not being * read. It sets nothing as it is asked, so a renderer may ask in its render. * It is new whenever the pages start afresh, and asks only for those. */ need(first: number, last: number): void; /** * Lets go of the pages far from `[first, last]`, past the most held; under * it, the same pages stay. It is new whenever the pages start afresh. */ keep(first: number, last: number): void; /** Starts the pages afresh, holding `pages`: what a reader does that learns its pages are addressed otherwise. */ reset(pages?: ReadonlyMap): void; } /** * Reads a collection a page at a time: see the module docs. * * @param reader - What the pages are of, how one is read, and the most held * @returns The pages, and how to ask for more and let go of some */ export declare function usePageReads(reader: PageReader): PageReads; //# sourceMappingURL=page-reads.d.ts.map