hey y'all :wave: I have a question about managing ...
# compose
i
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:
Copy code
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
d
DisposableEffect
might be what you're looking for.
i
oh this looks perfect, thank you!