InfiniteQuery
Every member of the InfiniteQuery namespace: queries that load a list one page at a time.
InfiniteQuery defines queries that load a list one page at a time, and loads more pages. Import it from the core entry point:
import { } from "@monarcode/effetch-query";Its exports follow, grouped by the guide that covers them. Each one has the first paragraph of its docs, and what it needs and how it fails; your editor shows the rest, with an example, when you hover the name.
Infinite queries
Guide: Infinite queries.
InfiniteQuery.make
Defines an InfiniteQuery with no arguments. Nothing is fetched until it's used; then its first page, from initialPageParam.
InfiniteQuery.family
Defines a Family: one InfiniteQuery per argument, each with its own pages.
InfiniteQuery.isInfiniteQuery
Checks whether a value is an InfiniteQuery, as opposed to a plain query or another atom.
InfiniteQuery.TypeId
The property that marks an InfiniteQuery, so it can be told apart from other queries.
InfiniteQuery.Family
Makes one InfiniteQuery per argument, as Query.family does: the same query for arguments that are Equal.equals, keyed by the family's key with the argument appended. It's a Query.Family, so it's a target for Query.invalidate (every query under its key), and Query.update writes every cached member.
InfiniteQuery.FamilyOptions
Options for family.
Prop
Type
InfiniteQuery.InfiniteData
What an InfiniteQuery holds: the pages loaded so far, in order, and the param each was fetched with.
InfiniteQuery.InfiniteQuery
A query whose value is a list of pages, for "load more" lists and infinite scroll, as TanStack's useInfiniteQuery. Create one with make, or one per argument with family.
InfiniteQuery.MakeOptions
Options for make.
Prop
Type
InfiniteQuery.PageOptions
How an infinite query finds its pages, in MakeOptions and FamilyOptions.
Prop
Type
InfiniteQuery.PageParamFunction
Finds the param of the page after the last one (nextPageParam) or before the first (previousPageParam), from that page, every page, its param and every param. Return undefined or null when there's no such page, as in TanStack.
Load more
Guide: Load more.
InfiniteQuery.fetchNextPage
Fetches the page after the last one and appends it, dropping the first page past maxPages. Returns the new InfiniteData, and fails with the query's error if the page fails (the loaded pages stay).
- With no next page (
nextPageParamgivesundefinedornull), it returns the data as it is, without fetching. - Without data, it's the query's first fetch, and joins it while it runs. With no pages (a write left none), it fetches from the first page, as TanStack does.
- While a next page is being fetched, it joins that fetch; while any other fetch of the query runs, it waits for it, then fetches its page.
- A write made while the page loads stays: the page is added to the data shown when it lands.
InfiniteQuery.fetchPreviousPage
Fetches the page before the first one and prepends it, dropping the last page past maxPages. Behaves as fetchNextPage does, in the other direction; without previousPageParam there's never a previous page.
Send the cache
Guide: Send the cache.
InfiniteQuery.Schema
How an infinite query's pages are sent from the server to the browser, as Query.Schema for a query: Schemas for a page and, to send failures too, the error. The page params go as they are, so they must be JSON values (strings, numbers, booleans, null), unless pageParam names their schema; a query whose params don't fit isn't sent.
Related pages
- Entry points: what each entry point exports.
@monarcode/effetch-query: the core entry point's namespaces and top-level names.Query: defining queries, keys and targets, and the cache from Effect.Mutation: defining and running mutations.Entity: records whose every cached copy a write updates.QueryClient: the client, its options and hooks, and server rendering.Signals: where a client hears about focus and reconnects.@monarcode/effetch-query/react: the provider, the hooks and the boundaries.@monarcode/effetch-query/effetch: queries and mutations from Effetch endpoints.@monarcode/effetch-query/react-native: focus and online signals for React Native.@monarcode/effetch-query/react/tanstack-router: connecting a client to TanStack Router and Start.