lazySingleton<T> abstract method

void lazySingleton<T>(
  1. dynamic factory(
    1. ContainerInterface
    )
)

Registers a lazy singleton factory for type T.

The factory is called only on the first resolution of T, and the instance is cached for future use. This differs from singleton in that the instance is not created until first needed.

  • factory: A function that takes the container and returns an instance of T.

Throws an exception if a binding for T already exists.

Implementation

void lazySingleton<T>(dynamic Function(ContainerInterface) factory);