bindSingleton

inline fun <T : Any> DI.Builder.bindSingleton(tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true, noinline creator: DirectDI.() -> T)

Binds a singleton: will create an instance on first request and will subsequently always return the same instance.

T generics will be erased!

Parameters

T

The created type.

creator

The function that will be called the first time an instance is requested. Guaranteed to be called only once. Should create a new instance.