ViewLifecycleCoroutineScope

class ViewLifecycleCoroutineScope : DispatchLifecycleScope

DispatchLifecycleScope instance which is tied to a Fragment's View lifecycle.

Functions

Link copied to clipboard
fun <T> Flow<T>.launchOnCreate(): Job

Every time the View Lifecycle State reaches CREATED, create a new coroutine and collect this Flow.

fun launchOnCreate(context: CoroutineContext = EmptyCoroutineContext, minimumStatePolicy: DispatchLifecycleScope.MinimumStatePolicy = MinimumStatePolicy.RESTART_EVERY, block: suspend CoroutineScope.() -> Unit): Job

Lifecycle-aware function for launching a coroutine any time the Lifecycle.State is at least Lifecycle.State.CREATED.

Link copied to clipboard
fun <T> Flow<T>.launchOnResume(): Job

Every time the View Lifecycle State reaches RESUMED, create a new coroutine and collect this Flow.

fun launchOnResume(context: CoroutineContext = EmptyCoroutineContext, minimumStatePolicy: DispatchLifecycleScope.MinimumStatePolicy = MinimumStatePolicy.RESTART_EVERY, block: suspend CoroutineScope.() -> Unit): Job

Lifecycle-aware function for launching a coroutine any time the Lifecycle.State is at least Lifecycle.State.RESUMED.

Link copied to clipboard
fun <T> Flow<T>.launchOnStart(): Job

Every time the View Lifecycle State reaches STARTED, create a new coroutine and collect this Flow.

fun launchOnStart(context: CoroutineContext = EmptyCoroutineContext, minimumStatePolicy: DispatchLifecycleScope.MinimumStatePolicy = MinimumStatePolicy.RESTART_EVERY, block: suspend CoroutineScope.() -> Unit): Job

Lifecycle-aware function for launching a coroutine any time the Lifecycle.State is at least Lifecycle.State.STARTED.

Properties

Link copied to clipboard
open override val coroutineContext: CoroutineContext
Link copied to clipboard
val lifecycle: Lifecycle

the lifecycle to which this MainImmediateCoroutineScope is linked.

Sources

Link copied to clipboard