When would I use a hilt custom component over a re...
# dagger
j
When would I use a hilt custom component over a regular dagger component? I cant find much info about this, aside from the docs which say:
Hilt components excel in situations where code needs to be contributed from possibly disjoint/modular code
But I don’t entirely understand what this means. Can regular dagger components not be composed from separate modules?
t
they can but it is usually via either subcomponents or comp-dependencies. neither of which are android lifecycle aware which IMO is a key part of what hilt provides. Then additionally managing the design of such a DI graph can be difficult in large codebases. If we could get dynamic scopes and/or sub/comp binding overrides you could create a sane treatise between biz application lifecycles and platform lifecycles. Then use anvil to fill in the module aggregation gap thus fully avoiding hilt. I typically advocate against using hilt because I think making the android life cycle the core dictating element of your DI graph design is a horrible and maybe even immoral idea. But I am just a crazy person.