Skip to content

Proper dependency injection (DI) #239

Answered by plusmobileapps
Knoxvillekm asked this question in Q&A
Discussion options

You must be logged in to vote

Like @arkivanov mentioned, you just need to pass things via the constructor so the necessity of a DI not required. If you were wanting to use some DI framework, it's worth mentioning that ComponentContext must be injected at run time because children are created with a new context from the router. So if you were to use something like kotlin-inject or kodein then you would have to use assisted injection. When I was messing around with decompose in an Android only app, I managed to get it working with Hilt if you wanted to check it out here. Otherwise I have another sample app that just creates is own DI using the features of the kotlin language.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by arkivanov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #238 on October 16, 2022 21:15.