import 'package:freezed_annotation/freezed_annotation.dart';

import 'loading_error.dart';

part 'loadable_state.freezed.dart';

@freezed
abstract class LoadableState<TState> with _$LoadableState<TState> {
  const LoadableState._();

  const factory LoadableState({
    required bool isLoading,
    required TState? data,
    required int? lastFetch,
    required void Function()? reFetch,
    required LoadingError? error,
    // Transient progress note under the primary loading spinner (e.g. retry
    // progress). Lives only within one fetch cycle — never persisted.
    String? statusText,
  }) = _LoadableState<TState>;

  bool showContent() => data != null;
}
