StatusRelay<TSourceBloc extends JuiceBloc<TSourceState> , TDestBloc extends JuiceBloc<BlocState> , TSourceState extends BlocState> class
Relays StreamStatus changes from one bloc to another.
Similar to StateRelay, but provides access to the full StreamStatus including waiting, failure, and canceling states. Use this when you need to react differently based on the status type.
Example
final relay = StatusRelay<AuthBloc, ProfileBloc, AuthState>(
toEvent: (status) => status.when(
updating: (state, _, __) => state.isAuthenticated
? LoadProfileEvent(userId: state.userId!)
: ClearProfileEvent(),
waiting: (_, __, ___) => ProfileLoadingEvent(),
failure: (_, __, ___) => ClearProfileEvent(),
canceling: (_, __, ___) => ClearProfileEvent(),
),
);
Constructors
-
StatusRelay({required EventBase toEvent(StreamStatus<
TSourceState> status), bool when(StreamStatus<TSourceState> status)?, Object? sourceScope, Object? destScope, BlocDependencyResolver? resolver}) - Creates a StatusRelay to connect two blocs via StreamStatus changes.
Properties
- destScope → Object?
-
Optional scope key for resolving destination bloc.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isClosed → bool
-
Whether this relay has been closed.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sourceScope → Object?
-
Optional scope key for resolving source bloc.
final
-
toEvent
→ EventBase Function(StreamStatus<
TSourceState> status) -
Function that transforms source StreamStatus into an event for destination bloc.
final
-
when
→ bool Function(StreamStatus<
TSourceState> status)? -
Optional predicate to filter which status changes should be relayed.
final
Methods
-
close(
) → Future< void> - Closes the relay and releases all resources.
-
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