How is Compose detecting that a new render needs to be done?
For example, when a state changes, but doesn't lead to changes in the tree. Which APIs let Compose UI for Android know that it needs to ask the system to redraw (calling invalidate)?
s
shikasd
12/27/2023, 3:11 PM
Usually state updates, most modifiers use
observerReads
to track layout/draw changes
l
louiscad
12/27/2023, 10:35 PM
What is
observerReads
? Where does it come from?
louiscad
01/01/2024, 9:29 PM
Digging deep, I found about the
SnapshotStateObserver
class, which has an
observeReads
function that executes a block and calls a callback when one of the states read inside said block was changed.
z
Zach Klippenstein (he/him) [MOD]
01/02/2024, 7:20 PM
draw is invalidated based on:
1. state reads inside draw* modifiers
2. changes in composition/layout phases
3. Modifier.Node invalidate calls
Maybe I forgot something, but i think those are the main paths