Saw this comment on reddit with a bunch of upvotes...
# compose
c
Saw this comment on reddit with a bunch of upvotes.
I'm building a new app with no DI. It's a breath of fresh air, to be frank.
CompositionLocalProvider currently serves the need I had for DI, and there's no sacrifice in testability (so far).
Is it find to use CompositionLocalProvider for this sort of stuff? https://www.reddit.com/r/androiddev/comments/mwjut9/dagger_hilt_is_now_stable_with_235/gvj2beu?utm_source=share&utm_medium=web2x&context=3
a
It depends whether you want your dependencies explicitly declared at each step and build-verified or implicitly located and fetched by the last mile that uses them. The former is verbose but transparent, the latter supports cross-cutting without altering intermediate API surfaces but the nature of those dependencies has to be carefully considered, especially around defaults.
For the purposes of this discussion, CompositionLocal is a service locator mechanism and all of the associated community discussion around DI vs. service locators applies
The whole thing can more or less be summarized by, "haha service locator go brrr"
😂 15