Why is `WindowSizeClass` not a `CompositionLocal`?
# compose
a
Why is
WindowSizeClass
not a
CompositionLocal
?
2
c
You can easily provide it yourself from your own Theme if you need it lower down in your hierarchy.
a
hmm yes, I could. I just was wondering why this was implemented in this way instead of providing it through CompositionLocal? 🤔
blob shrug 1
c
I think @Alex Vanyo worked on it? Maybe he has some background info on it?
a
There’s a bit of discussion back here: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1677359730475569 There’s no technical limitation preventing providing it as a
CompositionLocal
, you definitely can. The original concern against providing it in a
CompositionLocal
is that would make it too easy to use
WindowSizeClass
really deep in the tree, where it’d be better to have a more meaningful parameter or decision. But admittedly
Configuration
is available as a
CompositionLocal
so it’s not really a new problem. How many layers are you having to pass
WindowSizeClass
through, where it’s annoying to have to do so?
🤔 1