addSingleton<T> method

void addSingleton<T>(
  1. T factory(
    1. IocContainer container
    )
)

1️⃣ Add a singleton factory to the container. The container will only call this once throughout the lifespan of the container

Implementation

void addSingleton<T>(
  T Function(
    IocContainer container,
  )
      factory,
) =>
    addServiceDefinition<T>(
      ServiceDefinition<T>(
        (container) => factory(container),
        isSingleton: true,
      ),
    );