RefetchInterval class sealed Option values
Polling — the refetchInterval option.
While at least one observer with an interval is subscribed, the query is
refetched on that interval, whether its data is stale or not. Polling
pauses while the app is in the background unless
refetchIntervalInBackground is set, and stops when the last polling
observer unsubscribes. An interval polls even a StaleTime.static query.
Default: RefetchInterval.off.
refetchInterval: RefetchInterval.off // the default
refetchInterval: const RefetchInterval.every(Duration(seconds: 10))
// Poll a job until it is done, then stop:
refetchInterval: RefetchInterval.dynamic(
(query) => query.state.data == 'done' ? null : const Duration(seconds: 2),
)
- Implementers
- Annotations
-
- @immutable
Constructors
-
RefetchInterval.dynamic(Duration? compute(Query<
Object?> query)) -
Computed from the query each time the observer re-arms its timer
(TanStack Query:
refetchInterval: (query) => ms | false). Returningnullstops polling, which is how a poll can end once the data says it is done.constfactory - RefetchInterval.every(Duration interval)
-
Refetches every
intervalfor as long as an observer is subscribed (TanStack Query:refetchInterval: ms).constfactory
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) → Duration? -
The interval to poll
queryat;nullmeans "do not poll". -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- off → const RefetchInterval
-
No polling — the default (TanStack Query:
refetchInterval: false).