# compose

Ji Sungbin

05/23/2022, 4:49 PM
Every Layout composable emits a ReusableComposeNode. But what does Reusable mean here? Below is the code of ReusableComposeNode.
Copy code
@Composable inline fun <T : Any, reified E : Applier<*>> ReusableComposeNode(
    noinline factory: () -> T,
    update: @DisallowComposableCalls Updater<T>.() -> Unit
) {
    if (currentComposer.applier !is E) invalidApplier()
    if (currentComposer.inserting) {
        currentComposer.createNode { factory() }
    } else {
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 PM
We introduced it for use in LazyLists. Lazy node creation when possible is a recomposition of a previously scrolled-off node of the LazyList. Like any recomposition, it will skip the measure phase if all the inputs of measure are provably identical, otherwise it will remeasure.
Using the git blame layer on, I tracked down the patches where it was originally introduced: [1] and [2]

Ji Sungbin

05/24/2022, 2:16 AM
really thanks. l’ll check it. Can you help me with this too? I really haven’t figured this out yet. It is difficult for me to understand the many internal code by myself.

Andrey Kulikov

05/24/2022, 12:23 PM

this can explain the reusing logic

Ji Sungbin

05/24/2022, 12:32 PM
I’ve already seen that video, but I’ll watch it again! Thank you so much.