While testing my code, I got confused about Recomp...
# compose
l
While testing my code, I got confused about Recomposition. If I have a code like below, then what happens to
value
?
Copy code
var value = false
SomeComposable { item -> // content block
  if(item) value = true
  // etc.
}
SomeComposable internally runs for loop. Will it run like normal for loop? Will
content block
recompose by itself, making
value
inconsistent?
a
yes, code with this shape has those problems and it's best to avoid using things like accumulator variables that are mutated by child composables
l
But I thought Composables should run just like normal functions. It would be too burdening to expect such a thing like this.. So, how can I workaround them? I cannot afford modifing
SomeComposable
.
a
don't mutate
value
during child composition, since child composition can both skip and restart