Ian Sikes

    Ian Sikes

    1 year ago
    hey y'all 👋 I have a question about managing state in Jetpack Compose. Is there a way to perform some "cleanup" on a remember'd value before it is recomputed? I'm coming from React land where this is sort of thing is handled by
    useEffect
    . For example:
    val (session, setSession) = remember(sessionId) {
        mutableStateOf(Session(sessionId))
    }
    When the
    sessionId
    changes, a new
    Session
    is created. But I need to call
    session.close()
    beforehand. I can probably think of some hacky way to handle this but I'm trying to figure out what the "correct" Compose way is
    Dominaezzz

    Dominaezzz

    1 year ago
    DisposableEffect
    might be what you're looking for.
    Ian Sikes

    Ian Sikes

    1 year ago
    oh this looks perfect, thank you!