provideSingleton<T> function

void provideSingleton<T>(
  1. FactoryFunc<T> factory, {
  2. bool lazy = true,
})

Registers a singleton factory on the global active Bloom container.

The instance is created once and reused across all subsequent resolutions. If lazy is true (default), instantiation is deferred until first resolution.

Example

provideSingleton<DatabaseClient>(() => DatabaseClient());

Implementation

void provideSingleton<T>(FactoryFunc<T> factory, {bool lazy = true}) =>
    globalContainer.provideSingleton<T>(factory, lazy: lazy);