Hi there! Ihave recently been researching about co...
# compose
x
Hi there! Ihave recently been researching about composition locals in Compose. I've seen this answer by @jim and this other thread about it. I both like the idea of generally evading these implicit dependencies, but I also find really handy the composition locals provided in the Compose APIs. And this gets me thinking... if there's
n
reasonable use cases, won't it be an
n+1
case too? Are you aware of any other case were composition locals fit in neatly?
y
For me, you should never use them. There are a bunch of downsides under that implicit category. It's better to include your dependencies as params. And that's the difference, a platform concept like theme or viewmodel owner must be avoided as params on every method. For your own you can usually make them explicit params and then avoid passing everywhere by using slots
👆 2
👍 2