@Meer
Koin
Koin is a dependency injection framework (DI).
• It is DSL (Domain Specific Language), that makes it easy to read and code.
• It leverages the power of Kotlin’s DSL capabilities to provide a simple and declarative syntax for
defining dependencies and their relationships.
• It is essential concept to develop modern Android App.
• It is a light weight DI framework.
• It is fast and efficient, because it doesn't depends on extra code generation.
Gradle Setup
To start using Koin, add essentials dependencies in your project’s
build.gradle file inside dependency:
dependency {
}
Class Injection
1. Define a class 2. Provide dependency 3. Initialize Koin with module.
4. Injecting Dependency in MainActivity in another class of Android project.
Constructor Injection
1. Define classes. 2. Provide dependency
Initialization of module and
injecting dependency is same
as in class injection.
Interface Injection
1. Interface defining 3. Provide dependency
2. Interface Implementation
4. Injecting dependency in Activity
View Model Injection
• Dk • Dk
• Dffk
• Dk