copyWith method
ZenQueryConfig<T>
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> toJson(- T data
- ZenStorage? storage,
- T? placeholderData,
Create a copy with specific fields overridden
This provides a clean API for creating variants:
final baseConfig = ZenQueryConfig(staleTime: Duration.zero);
final withRetries = baseConfig.copyWith(retryCount: 5);
Implementation
ZenQueryConfig<T> 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 Function(Map<String, dynamic> json)? fromJson,
Map<String, dynamic> Function(T data)? toJson,
ZenStorage? storage,
T? placeholderData,
}) {
return ZenQueryConfig<T>(
staleTime: staleTime ?? this.staleTime,
cacheTime: cacheTime ?? this.cacheTime,
refetchOnMount: refetchOnMount ?? this.refetchOnMount,
refetchOnFocus: refetchOnFocus ?? this.refetchOnFocus,
refetchOnReconnect: refetchOnReconnect ?? this.refetchOnReconnect,
refetchInterval: refetchInterval ?? this.refetchInterval,
enableBackgroundRefetch:
enableBackgroundRefetch ?? this.enableBackgroundRefetch,
retryCount: retryCount ?? this.retryCount,
retryDelay: retryDelay ?? this.retryDelay,
maxRetryDelay: maxRetryDelay ?? this.maxRetryDelay,
retryBackoffMultiplier:
retryBackoffMultiplier ?? this.retryBackoffMultiplier,
exponentialBackoff: exponentialBackoff ?? this.exponentialBackoff,
retryWithJitter: retryWithJitter ?? this.retryWithJitter,
autoPauseOnBackground:
autoPauseOnBackground ?? this.autoPauseOnBackground,
refetchOnResume: refetchOnResume ?? this.refetchOnResume,
persist: persist ?? this.persist,
fromJson: fromJson ?? this.fromJson,
toJson: toJson ?? this.toJson,
storage: storage ?? this.storage,
placeholderData: placeholderData ?? this.placeholderData,
);
}