У меня проблема с введением класса данных.
Класс данных:
data class CoroutinesDispatcherProvider(
val main: CoroutineDispatcher,
val computation: CoroutineDispatcher,
val io: CoroutineDispatcher
)
И ViewModel нужен этот класс данных:
class MyViewModel(private val dispatcherProvider: CoroutinesDispatcherProvider):ViewModel() {
}
И, наконец, модуль:
val appModule = module {
single { (main: CoroutineDispatcher, computation: CoroutineDispatcher, io: CoroutineDispatcher) ->
CoroutinesDispatcherProvider(
main,
computation,
io
)
}
viewModel { MyViewModel(get()) }
}
Но получите ошибку:
Caused by: org.koin.error.BeanInstanceCreationException: Can't create definition for 'Factory [name='MyViewModel',class='com.example.myapplication.MyViewModel', binds~(androidx.lifecycle.ViewModel)]' due to error :
Can't create definition for 'Single [name='CoroutinesDispatcherProvider',class='com.example.myapplication.CoroutinesDispatcherProvider']' due to error :
Can't get parameter value #0 from org.koin.core.parameter.ParameterList@f87fb6
Что не так с appModule?!