ZenQueryConfig<T> class

Configuration for ZenQuery

Follows TanStack Query's pattern: all fields have concrete defaults, and configuration is merged explicitly rather than using nullable fields.

Annotations

Constructors

ZenQueryConfig({Duration staleTime = const Duration(seconds: 30), Duration cacheTime = const Duration(minutes: 5), RefetchBehavior refetchOnMount = RefetchBehavior.ifStale, RefetchBehavior refetchOnFocus = RefetchBehavior.never, RefetchBehavior refetchOnReconnect = RefetchBehavior.ifStale, NetworkMode networkMode = NetworkMode.online, Duration? refetchInterval, bool enableBackgroundRefetch = false, int retryCount = 3, Duration retryDelay = const Duration(milliseconds: 200), RetryDelayFn? retryDelayFn, Duration maxRetryDelay = const Duration(seconds: 30), double retryBackoffMultiplier = 2.0, bool exponentialBackoff = true, bool retryWithJitter = true, bool retryWhenOnline = false, bool autoPauseOnBackground = false, bool refetchOnResume = false, bool persist = false, T fromJson(Map<String, dynamic> json)?, Map<String, dynamic> toJson(T data)?, ZenStorage? storage, T? placeholderData})
const

Properties

autoPauseOnBackground → bool
Whether to automatically pause queries when app goes to background
final
cacheTime → Duration
How long inactive cache data remains in memory before garbage collection
final
enableBackgroundRefetch → bool
Whether to enable background refetching
final
exponentialBackoff → bool
Whether to use exponential backoff for retries
final
fromJson → T Function(Map<String, dynamic> json)?
Function to deserialize a Map<String, dynamic> into data (for hydration).
final
hashCode → int
The hash code for this object.
no setterinherited
maxRetryDelay → Duration
Maximum delay for retries (prevents infinite growth)
final
networkMode → NetworkMode
Network usage mode
final
persist → bool
Whether to persist this query's data
final
placeholderData → T?
Placeholder data to show while the query is loading. This does not persist to cache.
final
refetchInterval → Duration?
Interval for background refetching (null = disabled)
final
refetchOnFocus → RefetchBehavior
Whether to refetch when window gains focus
final
refetchOnMount → RefetchBehavior
Whether to refetch when component mounts
final
refetchOnReconnect → RefetchBehavior
Whether to refetch when network reconnects
final
refetchOnResume → bool
Whether to refetch stale data when resuming from background
final
retryBackoffMultiplier → double
Multiplier for exponential backoff (default: 2.0) Delay formula: min(retryDelay * (multiplier ^ attempt), maxRetryDelay)
final
retryCount → int
Number of retry attempts
final
retryDelay → Duration
Base delay between retries (used when retryDelayFn is null)
final
retryDelayFn → RetryDelayFn?
Custom function to calculate retry delay based on attempt and error
final
retryWhenOnline → bool
Whether to pause retrying when offline and resume automatically on reconnect
final
retryWithJitter → bool
Whether to add random jitter to retry delays (prevents thundering herd)
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
staleTime → Duration
How long data remains fresh before being considered stale
final
storage → ZenStorage?
Custom storage implementation (defaults to global storage if null)
final
toJson → Map<String, dynamic> Function(T data)?
Function to serialize data into a Map<String, dynamic> (for persistence).
final

Methods

cast<R>() → ZenQueryConfig<R>
Cast configuration to a new type
copyWith({Duration? staleTime, Duration? cacheTime, RefetchBehavior? refetchOnMount, RefetchBehavior? refetchOnFocus, RefetchBehavior? refetchOnReconnect, NetworkMode? networkMode, Duration? refetchInterval, bool? enableBackgroundRefetch, int? retryCount, Duration? retryDelay, RetryDelayFn? retryDelayFn, Duration? maxRetryDelay, double? retryBackoffMultiplier, bool? exponentialBackoff, bool? retryWithJitter, bool? retryWhenOnline, bool? autoPauseOnBackground, bool? refetchOnResume, bool? persist, T fromJson(Map<String, dynamic> json)?, Map<String, dynamic> toJson(T data)?, ZenStorage? storage, T? placeholderData}) → ZenQueryConfig<T>
Create a copy with specific fields overridden
merge(ZenQueryConfig<T>? other) → ZenQueryConfig<T>
Merge with another config (other's values take precedence)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Constants

defaults → const ZenQueryConfig
Standard library defaults