Alexander Maryanovsky

03/11/2022, 6:42 AM
Is there anything that helps with understanding what caused a recomposition, or why a
function is not being skipped?
👀 2

Thomas Dougherty

03/11/2022, 6:52 AM
Some notes I shared with my team the other day about Compose recompostuons: • Make sure any state objects you have only contain val and no var. This should be easy since state is supposed to be immutable anyways. • If you are using an interface as part of your state object, the interface has to be marked with @Stable or @Immutable so compose knows it can be used for smart recomposition • Currently Lists passed in trigger recomposition even if immutable. I believe there's a ticket for this to be fixed, one possible solution is to create a holder data class for lists that is marked immutable. • Implementing a lambda inline with a composable such as Header(onClick = { vm.handleclick() }) will cause recomposition. A few workarounds are: ◦ Hoisting up all unnecessary state and click handlers above the screen and passing them down ◦ Creating an anonymous object in a remember{} that holds all your click functions ◦ If your onClick takes no parameters, using method reference like ::onClick

Alexander Maryanovsky

03/11/2022, 6:54 AM
Thanks, that’s useful, but is there nothing to help with debugging recomposition causes?
🇳🇴 4

Thomas Dougherty

03/11/2022, 6:55 AM
As far as I know there's not support for that yet (I could be wrong as this stuff moves fast)

Alexander Maryanovsky

03/11/2022, 7:20 AM
Getting recomposition in a function that takes an enum and a Modifier 🤦
What do you all think of this suggestion?
At priority P4 someone may look at this again this century. Need more votes.

Shakil Karim

03/11/2022, 9:23 AM
i think i heard from @Adam Powell a while ago, about there will be some debugging tools for getting the information which param cause recomposition.
🎉 4

Jon Boekenoogen

03/11/2022, 3:31 PM
Can confirm that streamlined tools are in the works.

Colton Idle

03/13/2022, 4:46 AM
Just FYI: The play store had an article recently that included a modifier for recomposition highlighting.[…]le/android/compose/recomposehighlighter/RecomposeHighlighter.kt
👍🏻 1
😍 2
👍 22
👍🏽 1
👍🏼 1