bind

inline fun <Type : Any> bind(noinline provider: () -> Type)

Allows to bind a provider producing instances of the selected type.

Parameters

provider

will be bind with the selected type. If no type argument is passed, it will be bind to the same exact class as the object it provides.

Throws

if provider for the selected type is already defined.


inline fun <Type : Any> bind()

Automatically registers a provider for Type that will use reflection to create a new instance each time it is requested. All required constructor parameters will be extracted from Context. Note that the provider might throw InjectionException if any of the dependencies are missing, or com.badlogic.gdx.utils.reflect.ReflectionException when unable to construct an instance.

Parameters

Type

reified type of the provided instances. This class must have a single constructor.


fun <Type : Any> bind(vararg to: KClass<out Type>, provider: () -> Type)

Allows to bind a provider to multiple classes in hierarchy of the provided instances class.

Parameters

to

list of interfaces and classes in the class hierarchy of the objects provided by the provider. Any time any of the passed classes will be requested for injection, the selected provider will be invoked.

provider

provides instances of classes compatible with the passed types.

Throws

if provider for any of the selected types is already defined.