multiton

inline fun <C : Any, A : Any, T : Any> DI.BindBuilder.WithScope<C>.multiton(ref: RefMaker? = null, sync: Boolean = true, noinline creator: BindingDI<C>.(A) -> T): Multiton<C, A, T>

Creates a multiton: will create an instance on first request for each different argument and will subsequently always return the same instance for the same argument.

A & T generics will be erased!

Return

A multiton ready to be bound.

Parameters

A

The argument type.

T

The created type.

creator

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