Skip to content

Instantly share code, notes, and snippets.

@Rasalexman
Created June 24, 2019 19:59
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 Rasalexman/d7a7a7a7504ca0c08a9a91c9fae5912f to your computer and use it in GitHub Desktop.
Save Rasalexman/d7a7a7a7504ca0c08a9a91c9fae5912f to your computer and use it in GitHub Desktop.
class ViewModelFactory(appContext: Context) : ViewModelProvider.Factory, KodeinAware {
override val kodein: Kodein = (appContext as MainApplication).kodein // we can use `by kodein(appContext)` also
override fun <T : ViewModel> create(modelClass: Class<T>): T = kodein.direct.Instance(TT(modelClass))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment