tryAddSingleton<TService> method

void tryAddSingleton<TService>(
  1. ImplementationFactory implementationFactory
)

Adds the specified TService as a ServiceLifetime.singleton service using the factory specified in implementationFactory to the services if the service type hasn't already been registered.

Implementation

void tryAddSingleton<TService>(
  ImplementationFactory implementationFactory,
) {
  final descriptor = ServiceDescriptor.singleton<TService>(
    implementationFactory,
  );

  tryAdd(descriptor);
}