Hey folks, we are investigating Anvil as a DI solution. Is there a way to not add inject function to components for every activity or fragment and use some kind of generic solution?
r
ralf
11/10/2021, 4:01 PM
That’s a better question for #dagger. Anvil doesn’t change anything in this regard. I don’t have a good answer for you.
n
nitrog42
11/10/2021, 4:22 PM
is there any reason why you don't want to use Hilt for that ?
h
Hakob Astvacatryan
11/10/2021, 4:29 PM
@ralf good point. I will try to explain the problem. We try to keep modules as much isolated as possible so for injecting new object we don't want go to other module to put inject function there. For dagger as I know isolation is not possible so for dagger users it's okay to put injection function in other module’s component. So that's why usually they don't face this problem. But you are right actually it's question to dagger
Hakob Astvacatryan
11/10/2021, 4:29 PM
@nitrog42 We are planning to get rid of android core components such as activity fragment, view model so for other cases hilt is useless
👍 1
r
ralf
11/10/2021, 9:25 PM
@Hakob Astvacatryan I now understand what you’re asking. You can do this with Anvil: https://github.com/square/anvil#anvil
Look at the first sample. You want something similar like
ComponentInterface
.
👍 1
ralf
11/10/2021, 9:25 PM
This way you don’t need to touch any other module.