Last active
January 3, 2020 09:46
-
-
Save mlykotom/76e7ed10b3543d9f082ca059a45972e6 to your computer and use it in GitHub Desktop.
Connecting The Dots :: Motivation - manually added dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeFragment : Fragment() { | |
// inject into this class omitted for brevity | |
@Inject | |
lateinit var dep1: Dependency | |
@Inject | |
lateinit var dep2: Dependency | |
lateinit var viewModel : SomeViewModel | |
override fun onCreate(savedState: Bundle?){ | |
super.onCreate(savedState) | |
// retrieve articleId and pass it to your factory | |
val articleId = arguments!!.getString("article_id") | |
val factory = SomeViewModel.Factory(dep1, dep2, articleId) | |
viewModel = ViewModelProvider(this, factory).get(SomeViewModel::class.java) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment