register<Service, State> method

void register<Service, State>(
  1. Service builder(
    1. State state,
    2. ServiceLocator locator
    ),
  2. {String name}
)

Register a service builder which allows to call create.

If multiple instances of Services are needed, a name can be provided to identify a particular instance.

Implementation

void register<Service, State>(
    Service Function(State state, ServiceLocator locator) builder,
    {String name}) {
  final byType = _instanciators.putIfAbsent(
    Service,
    () => <String, ServiceBuilder>{},
  );
  byType[name ?? _defaultName] = (state) => builder(state, this);
}