Is there a way to update the variables without dir...
# compose
c
Is there a way to update the variables without directly reorganizing them?
remember { mutableStateOf(...) }
will be reorganized immediately after each
setValue
, but I just want to update the variable, and then manually reorganize and remember this variable at some point. what should I do?
k
use can
var value = remember { value }
without mutableState and another variable
var state = remember { stateOf(value) }
for ui. And can change state at some point
1
c
I'm very much obliged to you! In the end it should look like this:
Copy code
var stateSize by remember { mutableStateOf(0) }
var size = stateSize

try {
    xxx.forEach {
        size++
    }
} finally {
    state = size
}

Text(text = "last = $stateSize")
a
This looks a bit suspicious. What is the intent behind this code? This is very close to a pattern that will not behave as you might expect.