Skip to content

Instantly share code, notes, and snippets.

@mlykotom
Last active January 3, 2020 09:18
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 mlykotom/8bcf2835ef702036d4c149d2fab3eeb9 to your computer and use it in GitHub Desktop.
Save mlykotom/8bcf2835ef702036d4c149d2fab3eeb9 to your computer and use it in GitHub Desktop.
Connecting The Dots :: Motivation - manually added dependencies
class SomeViewModel(
private val dep1: Dependency,
private val dep2: Dependency2,
private val articleId: String
) : ViewModel() {
class Factory constructor(
private val dep1: Dependency,
private val dep2: Dependency2,
private val articleId: String
) : ViewModelProvider.Factory {
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return SomeViewModel(dep1, dep2, articleId) as T
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment