winter / io.jentz.winter / WinterApplication / inject

inject

fun inject(instance: Any): Unit

Inject dependencies into instance by using the dependency graph returned from InjectionAdapter.get called with instance.

Parameters

instance - The instance to retrieve the dependency graph for and inject dependencies into.

Exceptions

io.jentz.winter.WinterException - If given instance type is not supported.

fun inject(instance: Any, target: Any): Unit

Inject dependencies with dependency graph from instance into target. This uses the dependency graph returned from InjectionAdapter.get called with instance.

Usually we do not want knowledge of who owns a Graph in our application classes so the InjectionAdapter was created to hide that. But sometimes we find cases, especially on Android, where, for example, a class member function gets a Context passed into to do its work and we need that Context to retrieve the required dependency graph to inject the class dependencies into the class.

Parameters

instance - The instance to retrieve the dependency graph for.

target - The target to inject dependencies into.

Exceptions

io.jentz.winter.WinterException - If given instance type is not supported.