LifecycleCoroutineScope



CoroutineScope tied to a Lifecycle and Dispatchers.Main.immediate

This scope will be cancelled when the Lifecycle is destroyed.

Summary

Public functions

Job
launchWhenCreated(block: suspend CoroutineScope.() -> Unit)

This function is deprecated. launchWhenCreated is deprecated as it can lead to wasted resources in some cases.

android
Job
launchWhenResumed(block: suspend CoroutineScope.() -> Unit)

This function is deprecated. launchWhenResumed is deprecated as it can lead to wasted resources in some cases.

android
Job
launchWhenStarted(block: suspend CoroutineScope.() -> Unit)

This function is deprecated. launchWhenStarted is deprecated as it can lead to wasted resources in some cases.

android

Public functions

launchWhenCreated

fun launchWhenCreated(block: suspend CoroutineScope.() -> Unit): Job

Launches and runs the given block when the Lifecycle controlling this LifecycleCoroutineScope is at least in Lifecycle.State.CREATED state.

The returned Job will be cancelled when the Lifecycle is destroyed.

launchWhenResumed

fun launchWhenResumed(block: suspend CoroutineScope.() -> Unit): Job

Launches and runs the given block when the Lifecycle controlling this LifecycleCoroutineScope is at least in Lifecycle.State.RESUMED state.

The returned Job will be cancelled when the Lifecycle is destroyed.

launchWhenStarted

fun launchWhenStarted(block: suspend CoroutineScope.() -> Unit): Job

Launches and runs the given block when the Lifecycle controlling this LifecycleCoroutineScope is at least in Lifecycle.State.STARTED state.

The returned Job will be cancelled when the Lifecycle is destroyed.