singleton

inline fun <C : Any, T : Any> DI.BindBuilder.WithScope<C>.singleton(ref: RefMaker? = null, sync: Boolean = true, noinline creator: NoArgBindingDI<C>.() -> T): Singleton<C, T>

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

T generics will be erased!

Return

A singleton ready to be bound.

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.