Skip to content

Instantly share code, notes, and snippets.

@Rasalexman
Created June 24, 2019 19:58
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/02db218c26fbbdf9545a5cc8e35cd593 to your computer and use it in GitHub Desktop.
Save Rasalexman/02db218c26fbbdf9545a5cc8e35cd593 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