https://kotlinlang.org logo
#compose
Title
# compose
j

Ji Sungbin

05/25/2022, 5:43 PM
How can I make
currentComposer.recomposeScope
return null?
recomposeScope
comes from
invalidateStack
, and I thought
invalidateStack
would be empty when no referencing state inside. But it wasn’t. currentRecomposeScope code:
Copy code
internal val currentRecomposeScope: RecomposeScopeImpl?
    get() = invalidateStack.let {
        if (childrenComposing == 0 && it.isNotEmpty()) it.peek() else null
    }
Test code:
Copy code
@Composable
private fun Test() {
    val recomposeScope = currentRecomposeScope
    Box(modifier = Modifier.clickable { recomposeScope.invalidate(); println("Invalidate!") })
}
z

Zach Klippenstein (he/him) [MOD]

05/25/2022, 5:53 PM
Why do you want to make it return null?
j

Ji Sungbin

05/25/2022, 5:54 PM
for test. I just wanted to prove what I understood.
4 Views