https://kotlinlang.org logo
#compose
Title
# compose
l

lilypuchi

06/11/2022, 12:37 PM
I was reading Jorge’s Compose Internals (which if someone hasn’t read yet, I highly recommend to) I came across this (Pg 88 in the latest edition),
Copy code
In SubcomposeLayout for example, whenever a layout occurs, the parameters passed to its lambda might vary, and in that case it will trigger a recomposition. In the other hand, if a state that is read from a subcomposition changes, a recomposition will be scheduled for the parent Composition once the initial composition is performed.
How does one read read a state from a subcomposition 🤔 ? Is it same as reading state ‘in’ a subcomposition or am I reading it wrong?
s

shikasd

06/11/2022, 1:42 PM
Yep, should be equivalent to reading state /in/ subcomposition, judging by the context Not sure it is exactly correct though, because recomposer should only schedule recomposition for compositions the state was read in. So, if you only read some state in subcomposition, it shouldn't trigger any updates to the parent
l

lilypuchi

06/11/2022, 2:09 PM
if you only read some state in subcomposition, it shouldn’t trigger any updates to the parent
Yeah right, that’s why I am little confused blob sweat smile
@Jorge Castillo sorry to mention you .. but if you help clarify my misunderstanding
3 Views