UseCaseBuilder class

Standard implementation of UseCaseBuilderBase for creating use cases.

Connects an event type to a use case generator, enabling the bloc to route events to the appropriate handler.

Example:

class CounterBloc extends JuiceBloc<CounterState> {
  CounterBloc() : super(CounterState(), [
    () => UseCaseBuilder(
      typeOfEvent: IncrementEvent,
      useCaseGenerator: () => IncrementUseCase(),
    ),
    () => UseCaseBuilder(
      typeOfEvent: LoadDataEvent,
      useCaseGenerator: () => LoadDataUseCase(),
      initialEventBuilder: () => LoadDataEvent(), // Auto-fires on init
    ),
  ]);
}
Implemented types

Constructors

UseCaseBuilder({required Type typeOfEvent, required UseCaseGenerator useCaseGenerator, UseCaseEventBuilder? initialEventBuilder, EventConcurrency concurrency = EventConcurrency.concurrent})
Creates a use case builder.

Properties

concurrency EventConcurrency
How same-type events are processed relative to one another.
final
eventType Type
The type of event this use case handles.
no setteroverride
generator UseCaseGenerator
Creates the use case instance that will handle events.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
initialEventBuilder UseCaseEventBuilder?
Optional builder for creating an initial event when the bloc starts.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
typeOfEvent Type
The type of event this use case handles.
final
useCaseGenerator UseCaseGenerator
Function that creates the use case instance.
final

Methods

close() Future<void>
Cleanup method called when the use case is disposed.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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