https://kotlinlang.org logo
Title
l

Lance Gao

04/28/2023, 3:39 AM
Hi there, I am confused on the different between
lifecycleScope.launchWhenResumed
and
lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED)
, so could anyone explain it for me? Thanks in advance!
i

Ian Lake

04/28/2023, 3:44 AM
The blog post about
repeatOnLifecycle
talks about this: https://link.medium.com/qRILExz8lzb
tl/dr,
launchWhen
APIs would actually keep the flow active even when you weren't resumed, it would just pause actually delivering any results to your UI
While
repeatOnLifecycle
actually cancels the work when you go below that minimum state, ensuring you aren't wasting resources in the background
l

Lance Gao

04/28/2023, 3:46 AM
Thanks
e

Erick Sumargo

05/01/2023, 2:43 PM
And I heard
launchWhenX
is already deprecated in favor of
repeatOnLifecycle
https://twitter.com/manuelvicnt/status/1633823555208245248?t=REm1e2QS2Czq4Ed44hbCrg&s=19
s

Sergio C.

05/01/2023, 6:23 PM
I wonder when repeatOnLifecycle will be deprecated…