Do folk have any smart ways of discovering what ca...
# compose
d
Do folk have any smart ways of discovering what causes a recomposition? My ideal would be some log that says 'Because <name> state changed at <file:line>'? My use case is debugging 'jank' in
AnimatedContent
transitions because multiple recompositions are firing where conceptually there should be only one. Carefully tracing the code for state changes is a given, just wondering if people can share any smart breakpoints/profiling tricks they're employing?
d
What does the code using
AnimatedContent
looks like? Can you share the code?
d
transitionTo
is my own infix function to determine what kind of transition should be used; either
SlideLeft
or
SlideRight
if the workflow state represents another 'screen', or
None
if the new state represents a state change within the current 'screen'.
d
Can you try to read the target state passed to the content instead of reading
workFlowState
directly?
d
You mean where I have
with(workflowState)
... and any such usages below that?
d
yep, try
with (it) ...
d
Ok
It does look better!
Can you say what the underlying difference is?
Presumably this means that calling the collecting property delegate again causes it to reemit for all consumption points in the
@Composable
?
d
There are multiple sets of content that
AnimatedContent
is transitioning in between, each is associated with a different target state. Each set of the content ideally should only reflect what's defined in their corresponding target state. That would require that the content read the state passed to the content lambda. By reading an external state (i.e. workflowState), all the active content is observing that change, therefore causing unnecessary recomposition
d
Rolled the code back and forward again to compare - this really fixed it, thanks @Doris Liu! 🙏 🎉 Thanks for the explanation too; I've learned something about state handling today 😁
👍 2
Yes, I think I see now, even though it's the same state, reaching across scope to effectively learn the same thing twice caused double composition.