Making dependency injection
How Koin is making dependency injection
Injection by constructor
Dependency injection is firstly made in your components, by declaring how to build them with the Koin DSL.
In this module:
MyComponentB class can use directly its dependency:
Injecting into runtime components
Once your Koin module is loaded, you have to inject it into a runtime or particular app platform (Android, SparkKotlin …). You have two ways of injecting it into your runtime:
- Use an adapted Koin module, to help you to inject your module(s) into your runtime components (Activity, Fragments, Controller …)
- Tag a component as
Upgraded runtimes and KoinComponents main target are to bring
by inject() delegate instance getter, and other properties operators.
Check dedicated developer guides, to how to use dedicated koin modules.