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 will have to inject it into a runtime or particular app platform (Android, SparkKotlin …). You have two ways of injecting into your runtime:
- Use a adapted Koin module, to help you inject into runtime components (Activity, Fragments, Controller …)
- Tag a component as
Upgraded runtimes and KoinComponents mainly target to bring
by inject() delegate instance getter, and other properties operators.
Check dedicated development guides, to how to use dedicated koin modules.