StatusRelay<TSourceBloc extends JuiceBloc<TSourceState> , TDestBloc extends JuiceBloc<BlocState> , TSourceState extends BlocState> constructor
StatusRelay<TSourceBloc extends JuiceBloc<TSourceState> , TDestBloc extends JuiceBloc<BlocState> , TSourceState extends BlocState> ({
- required EventBase toEvent(
- StreamStatus<
TSourceState> status
- StreamStatus<
- bool when(
- StreamStatus<
TSourceState> status
- StreamStatus<
- Object? sourceScope,
- Object? destScope,
- BlocDependencyResolver? resolver,
Creates a StatusRelay to connect two blocs via StreamStatus changes.
Parameters:
toEvent- Function to transform source StreamStatus into a destination event.when- Optional predicate to filter which status changes trigger relay.sourceScope- Optional scope key for resolving source bloc.destScope- Optional scope key for resolving destination bloc.resolver- Optional resolver. If not provided, uses BlocScope.
Implementation
StatusRelay({
required this.toEvent,
this.when,
this.sourceScope,
this.destScope,
BlocDependencyResolver? resolver,
}) : _customResolver = resolver {
// Synchronous: a relay against an unregistered or closed bloc throws
// HERE, at construction, where the developer is looking — not as an
// uncaught error from a microtask nobody awaits.
_initialize();
}