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>({
  1. required EventBase toEvent(
    1. StreamStatus<TSourceState> status
    ),
  2. bool when(
    1. StreamStatus<TSourceState> status
    )?,
  3. Object? sourceScope,
  4. Object? destScope,
  5. 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();
}