m

    molikto

    2 years ago
    val s = state { 1 }
    Text(s.value.toString())
    remember {
        s.value = s.value + 1
    }
    it seems on dev08, updating a mutable state in the same frame will not triger recomposition? Is this a bug? (expected text should be "2")
    Andrey Kulikov

    Andrey Kulikov

    2 years ago
    hey! It is an expected behaviour right now. the state was created in the same frame so all the modifications on this state within the same frame are considered as the initial object constructions and not causing recomposition. @Chuck Jazdzewski [G] can provide more details, I remember we were discussion detection of the cases like this when we first read the value in the composition and then updated it in the same frame to handle it more smarter. but actually what exactly do you try to achieve with it? maybe this pattern is not a proper one for your usecase
    m

    molikto

    2 years ago
    I thought it used to work in previous versions, so if it is not the case, then it is not a bug. I already refactored that part of code to not read-then-write. but here is the code https://gist.github.com/molikto/2451bef072b52d2a4dbe39b9bd2f2981
    l

    Leland Richardson [G]

    2 years ago
    yes, this was changed intentionally for other reasons. we actually talked about this particular difference in behavior at length! But i didn’t think there would actually be any code in the wild that would be affected by it 😃