import '../../../../../api/marianumconnect/queries/get_breakers/get_breakers_cache.dart';
import '../../../../../api/marianumconnect/queries/get_breakers/get_breakers_response.dart';
import '../../../../../api/request_cache.dart';

class BreakerDataProvider {
  /// Resolves via [resolveFromCache] (not first-emit-wins): the cache emits its
  /// stored value first for an instant display, then the network value — and we
  /// return the latter once [RequestCache.ready] settles. `renew: true` forces a
  /// fresh network check on every call so a just-changed breaker takes effect on
  /// the next `refresh()` (app resume) instead of only after a restart.
  Future<GetBreakersResponse> getBreakers({
    bool renew = true,
    void Function(Object)? onError,
  }) => resolveFromCache<GetBreakersResponse>(
      (onUpdate, onError) =>
          GetBreakersCache(renew: renew, onUpdate: onUpdate, onError: onError),
      onError: onError,
      operationName: 'getBreakers',
    );
}
