Could you explain how I could inject dependecies into ViewModel constructor? I found a work around with Koin. I used KoinComponent interface and member injection. But I am not sure it is best way to do it
class RandomizeViewModel :
BaseSharedViewModel<RandomizeViewState, RandomizeAction, RandomizeEvent>(
initialState = RandomizeViewState.Idle
),
KoinComponent {
val getRandomDrinkUseCase: GetRandomDrinkUseCase by inject()
override fun obtainEvent(viewEvent: RandomizeEvent) { }
}
Hello. We use this option with member injection. In general constructor injection – isn't the library's responsibility. You can add your viewmodel to DI graph and get it, for example, in compose screen
Could you explain how I could inject dependecies into ViewModel constructor? I found a work around with Koin. I used KoinComponent interface and member injection. But I am not sure it is best way to do it