factory

inline fun <A : Any, T : Any> DirectDI.factory(tag: Any? = null): (A) -> T

Gets a factory of T for the given argument type, return type and tag.

A & T generics will be preserved.

Return

A factory.

Parameters

A

The type of argument the factory takes.

T

The type of object the factory returns.

tag

The bound tag, if any.

Throws

DI.NotFoundException

if no factory was found.

DI.DependencyLoopException

When calling the factory function, if the instance construction triggered a dependency loop.

inline fun <A : Any, T : Any> DIAware.factory(tag: Any? = null): LazyDelegate<(A) -> T>

Gets a factory of T for the given argument type, return type and tag.

A & T generics will be preserved!

Return

A factory.

Parameters

A

The type of argument the factory takes.

T

The type of object the factory returns.

tag

The bound tag, if any.

Throws

if no factory was found.

When calling the factory function, if the instance construction triggered a dependency loop.


inline fun <A : Any, T : Any> DirectDIAware.factory(tag: Any? = null): (A) -> T

Gets a factory of T for the given argument type, return type and tag.

A & T generics will be erased.

Return

A factory.

Parameters

A

The type of argument the factory takes.

T

The type of object the factory returns.

tag

The bound tag, if any.

Throws

if no factory was found.

When calling the factory function, if the instance construction triggered a dependency loop.


inline fun <A : Any, T : Any> Named.factory(): LazyDelegate<(A) -> T>

Gets a factory of T for the given argument type and return type. The name of the receiving property is used as tag.

A & T generics will be erased!

Return

A factory.

Parameters

A

The type of argument the factory takes.

T

The type of object the factory returns.

Throws

if no factory was found.

When calling the factory function, if the instance construction triggered a dependency loop.


inline fun <C : Any, A : Any, T : Any> DI.BindBuilder<C>.factory(noinline creator: BindingDI<C>.(A) -> T): Factory<C, A, T>

Creates a factory: each time an instance is needed, the function creator function will be called.

A & T generics will be erased!

Return

A factory ready to be bound.

Parameters

A

The argument type.

T

The created type.

creator

The function that will be called each time an instance is requested. Should create a new instance.