-
Notifications
You must be signed in to change notification settings - Fork 0
koin: Injecting the interface in constructor of viewModel
Devrath edited this page Mar 7, 2024
·
1 revision
interface HelloService {
fun doSomething(): String
}
class HelloServiceImpl : HelloService {
override fun doSomething(): String {
return "Hello Service, Koin!"
}
}
val viewModelModules = module {
viewModel { VariableInjectionVm(get()) }
}
class VariableInjectionVm(
private val helloService: HelloService
) : ViewModel() {
fun demo(): String {
return helloService.doSomething()
}
}