register<TBloc extends JuiceBloc<BlocState>> method

TBloc register<TBloc extends JuiceBloc<BlocState>>(
  1. TBloc factory()
)

Registers TBloc in BlocScope as a permanent bloc, builds it at once, and watches it as add does. Returns the instance — the one a reaction that names TBloc by type resolves.

Implementation

TBloc register<TBloc extends JuiceBloc<BlocState>>(TBloc Function() factory) {
  _checkRunning();
  BlocScope.register<TBloc>(factory, lifecycle: BlocLifecycle.permanent);
  return add(BlocScope.get<TBloc>());
}