onClose method

  1. @override
void onClose()
override

User-defined cleanup hook - called before internal disposal

Implementation

@override
void onClose() {
  _isDisposed = true;
  _refetchTimer?.cancel();
  _refetchTimer = null;
  _currentFetch = null;

  // Unregister based on how it was registered
  if (_registerInCache) {
    if (scope != null) {
      final scopedKey = '${scope!.id}:$queryKey';
      ZenQueryCache.instance.unregister(scopedKey);
    } else {
      ZenQueryCache.instance.unregister(queryKey);
    }
  }

  // Dispose notifiers
  status.dispose();
  data.dispose();
  error.dispose();
  enabled.dispose();
  _isLoadingNotifier?.dispose();

  super.onClose();
}