Ji Sungbin
05/23/2022, 4:49 PM@Composable inline fun <T : Any, reified E : Applier<*>> ReusableComposeNode(
noinline factory: () -> T,
update: @DisallowComposableCalls Updater<T>.() -> Unit
) {
if (currentComposer.applier !is E) invalidApplier()
currentComposer.startReusableNode()
if (currentComposer.inserting) {
currentComposer.createNode { factory() }
} else {
currentComposer.useNode()
}
currentComposer.disableReusing()
Updater<T>(currentComposer).update()
currentComposer.enableReusing()
currentComposer.endNode()
}
I noticed with this code that the only difference between ReusableComposeNode and ComposeNode is the way the groups are created. The KDoc of startReusableNode(), which is the group creation method used in ReusableComposeNode, is written as follows.
Start a group that tracks a the code that will create or update a node
that is generated as part of the tree implied by the composition. A
reusable node can be reused in a reusable group even if the group key
is changed.I don’t know what reused means here. Does this mean that the node is reused as measured? (normal nodes will start with the measure phase. but does the reused node skip the measured phase?)
Alexandre Elias [G]
05/23/2022, 11:39 PMAlexandre Elias [G]
05/23/2022, 11:41 PMJi Sungbin
05/24/2022, 2:16 AMJi Sungbin
05/24/2022, 3:03 AMJi Sungbin
05/24/2022, 12:32 PM