RefetchOn class sealed Option values

Whether an event refetches an observed query — the value of the refetchOnMount, refetchOnWindowFocus and refetchOnReconnect options.

The events are: an observer subscribing (mount), the app regaining focus (AppFocusManager-driven), and the network coming back (OnlineManager-driven). A disabled query is never refetched by any of them.

Default: RefetchOn.ifStale for all three — except refetchOnReconnect on a query whose networkMode is NetworkMode.always, which defaults to RefetchOn.never since such a query never waited for the network in the first place.

TanStack Query spells this true | false | 'always' | (query) => …; ifStale is its true, named for what it does.

refetchOnWindowFocus: RefetchOn.never
refetchOnMount: RefetchOn.always   // even if the data is fresh
refetchOnReconnect: RefetchOn.ifStale  // the default
refetchOnWindowFocus: RefetchOn.when(
  (query) => query.state.error != null ? RefetchOn.always : RefetchOn.never,
)
Implementers
Annotations
  • @immutable

Constructors

RefetchOn.when(RefetchOn compute(Query<Object?> query))
Decided per query when the event fires (TanStack Query: (query) => boolean | 'always').
const
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolve(Query<Object?> query) → RefetchOn
This with any RefetchOn.when layer peeled off for query, so the result is never, ifStale or always.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

always → const RefetchOn
The event always triggers a refetch, fresh data or not (TanStack Query: 'always').
ifStale → const RefetchOn
The event triggers a refetch only when the data is stale — the default for mount, focus and reconnect (TanStack Query: true).
never → const RefetchOn
The event never triggers a refetch (TanStack Query: false).