Koin
Koin is a lightweight and pragmatic dependency injection (DI) framework specifically designed for Kotlin applications. It provides a clean and declarative approach to managing dependencies within your app, promoting modularity and testability.
Usage
Dependencies
Within your app
module’s build.gradle.kts
file, incorporate the following dependencies:
implementation(project(":di:koin"))
Example
In your application’s App.kt
file, initialize Koin within the onCreate
method:
KoinInitializer.init(applicationContext)
Optional: Customizing Modules
KoinInitializer.init(applicationContext, modules = myListOfModules)
Alternatively, you can directly add your modules to the KoinInitializer
by defining them within the init method itself.
Default Behavior
By default, both methods for adding modules are empty. This means no modules will be loaded unless you explicitly define them.
More information on Koin can be found in the official documentation .