bind<T extends MineralService> method

T bind<T extends MineralService>(
  1. T service(
    1. Ioc ioc
    )
)

Registers a new service within the IOC. class MyService {}

final myService = ioc.bind((ioc) => MyService());
print(myService);

Implementation

T bind<T extends MineralService> (T Function(Ioc ioc) service) {
  if (_services.containsKey(service)) {
    throw ServiceAlreadyRegisteredException(T);
  }

  final T instance = service(this);

  _services.putIfAbsent(instance.runtimeType, () => instance);
  return instance;
}