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), bool refetchOnMount = true, bool refetchOnFocus = false, bool refetchOnReconnect = true, Duration? refetchInterval, bool enableBackgroundRefetch = false, int retryCount = 3, Duration retryDelay = const Duration(milliseconds: 200), Duration maxRetryDelay = const Duration(seconds: 30), double retryBackoffMultiplier = 2.0, bool exponentialBackoff = true, bool retryWithJitter = true, 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 data remains in cache
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 convert JSON to data (for hydration)
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxRetryDelay → Duration
-
Maximum delay for retries (prevents infinite growth)
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 → bool
-
Whether to refetch when window gains focus
final
- refetchOnMount → bool
-
Whether to refetch when component mounts
final
- refetchOnReconnect → bool
-
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 (e.g., 200ms)
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
final
- storage → ZenStorage?
-
Custom storage implementation (defaults to global storage if null)
final
-
toJson
→ Map<
String, dynamic> Function(T data)? -
Function to convert data to JSON (for persistence)
final
Methods
-
cast<
R> () → ZenQueryConfig< R> - Cast configuration to a new type
-
copyWith(
{Duration? staleTime, Duration? cacheTime, bool? refetchOnMount, bool? refetchOnFocus, bool? refetchOnReconnect, Duration? refetchInterval, bool? enableBackgroundRefetch, int? retryCount, Duration? retryDelay, Duration? maxRetryDelay, double? retryBackoffMultiplier, bool? exponentialBackoff, bool? retryWithJitter, 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