Skip to content

Instantly share code, notes, and snippets.

@oradkovsky
Created April 28, 2020 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oradkovsky/a6d0cd645303496f7df053e0a9085580 to your computer and use it in GitHub Desktop.
Save oradkovsky/a6d0cd645303496f7df053e0a9085580 to your computer and use it in GitHub Desktop.
// declare view model
class MyViewModel(private val gson: Gson) : ViewModel() {
//...
}
// modify corresponding module
val viewModelsModule = module {
viewModel { MyViewModel(get()) }
}
// make use of it!
// extension function is in use: org.koin.androidx.viewmodel.ext.android
class MyFragment : Fragment() {
private val myViewModel: MyViewModel by viewModel()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment