Thread
#compose
    Chachako

    Chachako

    1 year ago
    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?
    Karthick

    Karthick

    1 year ago
    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
    Chachako

    Chachako

    1 year ago
    I'm very much obliged to you! In the end it should look like this:
    var stateSize by remember { mutableStateOf(0) }
    var size = stateSize
    
    try {
        xxx.forEach {
            size++
        }
    } finally {
        state = size
    }
    
    Text(text = "last = $stateSize")
    Adam Powell

    Adam Powell

    1 year ago
    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.