BlocUseCase<TBloc extends JuiceBloc<BlocState>, TEvent extends EventBase> class abstract

Base class for bloc-specific use cases that provides logging and naming capabilities.

TBloc - The type of bloc this use case works with TEvent - The type of event this use case handles

This abstract class provides common functionality for all bloc use cases including:

  • Automatic use case naming
  • Structured logging with context support
  • Error tracking
Inheritance
Implementers

Constructors

BlocUseCase()

Properties

bloc ↔ TBloc
Reference to the bloc that owns this use case. Set automatically by the framework via setBloc.
getter/setter pairinherited
emitCancel ↔ void Function({Map<String, dynamic>? aviatorArgs, String? aviatorName, Set<String>? groupsToRebuild, BlocState? newState})
Emits a cancellation state to indicate the operation was cancelled.
getter/setter pairinherited
emitEvent ↔ void Function({EventBase? event})
Emits a raw event without changing state.
getter/setter pairinherited
emitFailure ↔ void Function({Map<String, dynamic>? aviatorArgs, String? aviatorName, Object? error, StackTrace? errorStackTrace, Set<String>? groupsToRebuild, BlocState? newState})
Emits a failure state to indicate operation failure.
getter/setter pairinherited
emitUpdate ↔ void Function({Map<String, dynamic>? aviatorArgs, String? aviatorName, Set<String>? groupsToRebuild, BlocState? newState, bool skipIfSame})
Emits an update state to indicate successful operation completion.
getter/setter pairinherited
emitWaiting ↔ void Function({Map<String, dynamic>? aviatorArgs, String? aviatorName, Set<String>? groupsToRebuild, BlocState? newState})
Emits a waiting state to indicate operation in progress.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
useCaseName String
Name of the use case, automatically set from the runtime type
latefinal

Methods

close() → void
Performs cleanup when the use case is no longer needed.
inherited
execute(TEvent event) Future<void>
Execute the use case logic for the given event.
override
guardEntity<K, T>(K key, {required EntityStatuses<K> read(TBloc bloc), required BlocState write(EntityStatuses<K> statuses), required Future<T> action(), Set<String>? groupsToRebuild, bool rethrowOnError = false}) Future<T?>
Runs action while tracking a single entity's async status in your state, guaranteeing the entity is set to waiting before, idle after — or failure if action throws (cleanup happens even on error, killing the stuck-spinner footgun). The per-entity analogue of the emitWaiting → emitUpdate/emitFailure lifecycle.
log(String message, {Level level = Level.info, Map<String, dynamic>? context}) → void
Logs a message with the use case name as prefix.
logError(Object error, StackTrace stackTrace, {Map<String, dynamic>? context}) → void
Logs an error with stack trace and use case name as prefix.
logState(String stateDescription, {Map<String, dynamic>? context}) → void
Logs the current state with the use case name as prefix.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setBloc(JuiceBloc<BlocState> blocInstance) → void
Sets the bloc reference for this use case.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited