copyWith method

ZenQueryConfig<T> copyWith({
  1. Duration? staleTime,
  2. Duration? cacheTime,
  3. bool? refetchOnMount,
  4. bool? refetchOnFocus,
  5. bool? refetchOnReconnect,
  6. Duration? refetchInterval,
  7. bool? enableBackgroundRefetch,
  8. int? retryCount,
  9. Duration? retryDelay,
  10. Duration? maxRetryDelay,
  11. double? retryBackoffMultiplier,
  12. bool? exponentialBackoff,
  13. bool? retryWithJitter,
  14. bool? autoPauseOnBackground,
  15. bool? refetchOnResume,
  16. bool? persist,
  17. T fromJson(
    1. Map<String, dynamic> json
    )?,
  18. Map<String, dynamic> toJson(
    1. T data
    )?,
  19. ZenStorage? storage,
  20. 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,
  );
}