Skip to content

Instantly share code, notes, and snippets.

@lamvann
Created April 28, 2020 19:55
Show Gist options
  • Save lamvann/64b78aeeb67f61bc28a936d8c0579d2c to your computer and use it in GitHub Desktop.
Save lamvann/64b78aeeb67f61bc28a936d8c0579d2c to your computer and use it in GitHub Desktop.
Adding viewModel property to BaseFragment using Koin with reflection
private val viewModelClass =
(javaClass
.genericSuperclass as ParameterizedType)
.actualTypeArguments[0] as Class<ViewModelType>
val viewModel: ViewModelType by lazy { getViewModel(clazz = viewModelClass.kotlin) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment