I am trying to implement the example on https://developer.android.com/jetpack/docs/guide. This explains how tan android app should be structured.
When I use the same
You can use Koin as an alternative for Dagger. Koin have full support of Android Architecture ViewModel. It's extremely easy to use. I prefer it for small and mid-sized project.
// declared ViewModel using the viewModel keyword
val myModule : Module = module {
viewModel { MyViewModel(get()) }
...
}
// Just get it
class MyActivity() : AppCompatActivity() {
// lazy inject MyViewModel
val myViewModel : MyViewModel by viewModel()
}
insert-koin.io