Hi there, I am confused on the different between `...
# android
l
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!
not kotlin but kotlin colored 1
👍 1
i
The blog post about
repeatOnLifecycle
talks about this: https://link.medium.com/qRILExz8lzb
👍 2
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
👍 5
While
repeatOnLifecycle
actually cancels the work when you go below that minimum state, ensuring you aren't wasting resources in the background
👍 6
l
Thanks
e
And I heard
launchWhenX
is already deprecated in favor of
repeatOnLifecycle
https://twitter.com/manuelvicnt/status/1633823555208245248?t=REm1e2QS2Czq4Ed44hbCrg&s=19
s
I wonder when repeatOnLifecycle will be deprecated…