registerSingleton<S> method

void registerSingleton<S>(
  1. FactoryBuilder<S> factory, {
  2. String? name,
})

Registers a factory that will be called only only when accessing it for the first time, into the container.

A factory returning an object of type S can be registered.

If name is set, the factory will be registered under this name. To retrieve the same factory, the same name should be provided to KiwiContainer.resolve.

Implementation

void registerSingleton<S>(
  FactoryBuilder<S> factory, {
  String? name,
}) {
  _setProvider(name, _Provider<S>.singleton(factory));
}