Per-HonuaProvider cache of query results. Not a React construct; it is driven by the hooks via subscribe / getSnapshot / ensure.

Constructors

Methods

  • Kick off a fetch for key when it has never resolved and is not already in flight. This is the idempotent entry point hooks call from an effect; StrictMode's double-invoke therefore does not double-fetch.

    With options.staleTimeMs, a resolved entry whose data is at least that old is additionally revalidated in the background (stale-while-revalidate: the cached data stays served while isFetching is true). 0 revalidates on every ensure; omitted keeps the historical never-revalidate behavior.

    Type Parameters

    • T

    Parameters

    • key: string
    • fetcher: QueryFetcher<T>
    • options: {
          staleTimeMs?: number;
      } = {}
      • OptionalstaleTimeMs?: number

    Returns void

  • Experimental

    The promise of the in-flight run for key, or undefined when no fetch is running. Suspense-mode hooks throw this promise while the first load is pending; it never rejects (errors land on the snapshot instead).

    Parameters

    • key: string

    Returns undefined | Promise<unknown>

  • Subscribe listener to changes for key. When the final listener for a key unsubscribes and a fetch is still in flight, the fetch is aborted so unmounting the last consumer cancels the underlying request.

    Parameters

    • key: string
    • listener: (() => void)
        • (): void
        • Returns void

    Returns (() => void)

      • (): void
      • Returns void