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

Mehdi Haghgoo

09/07/2020, 4:37 AM
Hey. What is a RecomposeScope mentioned in the following paragraph (Sorry it sounds like a TOEFL question! lol)?
MutableState: A mutable value holder where reads to the value property during the execution of a Composable function, the current RecomposeScope will be subscribed to changes of that value. When the value property is written to and changed, a recomposition of any subscribed RecomposeScopes will be scheduled. If value is written to with the same value, no recompositions will be scheduled.
s

Sean McQuillan [G]

09/07/2020, 5:07 AM
A recompose scope is the actual restarting block of a composable. For example, a composable function adds a recompose scope, and the item block to an lazy column adds a recompose scope. The "Thinking in Compose" page gets into this a bit when explaining how compose skips as much as possible: https://developer.android.com/jetpack/compose/mental-model#skips cc @Leland Richardson [G]
m

Mehdi Haghgoo

09/07/2020, 6:47 AM
So, @Sean McQuillan [G] a Composable's scope is considered its Recompose scope. I mean the whole space available inside the composable's body (content lambda) between
{
and
}
, right? I'm not sure if my definition of scope is correct.
s

Sean McQuillan [G]

09/08/2020, 10:52 PM
Yep, all composable functions define a new restart scope. Inside a single composable function body, there may be multiple recompose scopes, usually created with lambdas.
24 Views