Proper dependency injection (DI) #239
-
How to use it, any sample plz. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hello. You can just pass things via constructors, see example. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
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.