https://kotlinlang.org logo
#compose
Title
# compose
h

Hengjiang Liu

02/10/2023, 3:25 AM
Dose anyone know that when the
onForgotten
of
LaunchedEffect
would be executed? I faced a problem that my job inside
LaunchedEffect
is canceled and I don’t know the reason.
s

Stylianos Gakis

02/10/2023, 5:45 AM
That job will be cancelled when either 1. One of the keys changes, therefore the old job is cancelled and a new one starts. 2. The composable exits composition entirely, cancelling the job and not starting a new one after that
h

Hengjiang Liu

02/10/2023, 5:47 AM
Thanks for replying. for 2 : Is it just like
onDispose
for this composable?
s

Stylianos Gakis

02/10/2023, 5:55 AM
I am not sure what you are referring to when you say
onDispose
. For
LaunchedEffect
there’s not such function, for
DisposableEffect
yes,
onDispose
would be called in this case when the composable exits composition if that’s what you are asking.
3 Views