In <this article> a Google Dev recommends using `L...
# compose
a
In this article a Google Dev recommends using
Lifecycle.STARTED
for flow collection, so that collection ends when the app is sent to the background, but the following code cancels and resumes at the same time in my testing (rotation, sending app into the background via home button, switching apps etc) Can someone tell me when there will be a tangible difference between using the
Lifecycle.STARTED
and just using
LaunchedEffect
? Code:
Copy code
LaunchedEffect(Unit) {
        try {
            Log.v("LaunchedEffect", "LaunchedEffect scope started")
            delay(10_000_000)
        } catch (cancellation: CancellationException) {
            Log.v("LaunchedEffect", "LaunchedEffect scope ended")
        }
    }

    val lifecycle = LocalLifecycleOwner.current
    LaunchedEffect(Unit) {
        lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
            try {
                Log.v("LaunchedEffect", "Lifecycle scope started")
                delay(10_000_000)
            } catch (cancellation: CancellationException) {
                Log.v("LaunchedEffect", "Lifecycle scope ended")
            }
        }
    }
@Manuel Vivo Since you wrote the article, maybe you can help me out 😄