InfiniteQuery
A window over an ordered live query: the first
pageSize
times the number of pages rows of its result. Widening it
shows rows the db holds at once and loads more from the query's loader only when the window runs past them.
The window belongs to this instance, so two components showing the same query share its live query and its subset, and each keeps its own number of pages.
import { InfiniteQuery } from "@hyper-fetch/db"
Parameters
class InfiniteQuery<Item> {
constructor(runtime: DbRuntime, definition: QueryDefinition, options: InfiniteQueryOptions) {};
key: string;
fetchNextPage() => Promise<void>;
getSnapshot() => InfiniteQueryState<Item>;
refetch() => Promise<void>;
subscribe(listener: () => void) => () => void;
}
| Name | Type | Description |
|---|---|---|
| runtime | | |
| definition | | |
| options | |
Methods
fetchNextPage()
Widens the window by one page. Rows the db holds show at once, and the loader loads more when the window runs past them. Resolves once the window is filled or the backend has no more rows.
Preview
fetchNextPage()
Returns
Promise<void>
getSnapshot()
Preview
getSnapshot()
Returns
| Name | Type | Description |
|---|---|---|
| data | |
|
| error | | The last failure, also when a refresh failed and the rows stay |
| hasNextPage | | Whether a paginated query has another page |
| isFetching | | Whether a request for the query is in flight |
| stale | | Whether the rows may be out of date: their subset is stale or its syncs are disconnected |
| status | |
|
| isFetchingNextPage | | Whether more rows are loading to fill the window after
|
| pages | |
|
subscribe()
Preview
subscribe(listener: () => void)
Parameters
| Name | Type | Description |
|---|---|---|
| listener | |
Returns
() => void
