Thread
#compose
    tjohnn

    tjohnn

    2 years ago
    In what scenario should I use
    remember { state }
    rather than just
    state
    ? I have tried and my app works thesame way.
    Adam Powell

    Adam Powell

    2 years ago
    that depends on what
    state
    is. Do you have a more specific example?
    tjohnn

    tjohnn

    2 years ago
    The state is a mutableStateOf<SomeDataClass>() @Adam Powell
    And the state is created from StateFlow.observeAsState()
    Adam Powell

    Adam Powell

    2 years ago
    you do not need to
    remember
    it yourself then
    observeAsState
    is responsible for maintaining its persistence guarantees across recomposition
    tjohnn

    tjohnn

    2 years ago
    Okay thanks. Can you share a resource on remember{}, I’m still confused on it
    Adam Powell

    Adam Powell

    2 years ago
    I'm looking around to see what we have published, the kdocs on remember itself are kind of thin at the moment
    a way to think about it is that it creates an instance field for a composable
    generally speaking you should
    remember
    things you create and want to persist across recompositions, and count on other composable functions to do the same
    tjohnn

    tjohnn

    2 years ago
    Okay thank you, I think I got it to some extent, would research more