Skip to content

Instantly share code, notes, and snippets.

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