This message was deleted.
# compose
s
This message was deleted.
m
Based on the last example shown in this article, I expected depths 1–2 to be skipped on recomposition, but they aren’t. Why are they still getting recomposed when their lambdas don’t contain any invalidated reads?
m
Because you are reading the state :
Copy code
val read = counter
in scope depth 0 so it cause the whole composable lambda to be recomposed.
m
Copy code
SCOPE   com.example.reactivity D    depth 0
SCOPE   com.example.reactivity D    depth 1
SCOPE   com.example.reactivity D    depth 2
SCOPE   com.example.reactivity D    depth 3
SCOPE   com.example.reactivity D    depth 4
SCOPE   com.example.reactivity D    depth 1
SCOPE   com.example.reactivity D    depth 2
SCOPE   com.example.reactivity D    depth 3
SCOPE   com.example.reactivity D    depth 4
What do you mean?
depth 0
is skipped for some reason
m
I mean the lambda that is passed to
depth 0
is reading the state, so the whole lambda will be recomposed on state changes.
You can try removing this line:
Copy code
val read = counter
and it should skip depth1 and depth2 and I believe even depth 3 should be skipped.
m
I understand that removing that enables donut hole skipping but the blog post has it working even with the read in the toplevel scope?
Jesus christ I think the blog post is wrong. Why is there so much misinformation? Or am I mistaken? Somebody please tell me
Wait the example from the blog does work with a read that gets invalidated in the toplevel scope
The blog post has an example with a read that gets invalidated in the toplevel scope where doughnut hole skipping still works, but mine doesn’t. I don’t know what’s causing this discrepancy
m
Can you send the example here.