Package dispatch.android.lifecycle

Types

Link copied to clipboard
open class DispatchLifecycleScope(lifecycle: Lifecycle, coroutineContext: CoroutineContext) : MainImmediateCoroutineScope
Link copied to clipboard
class DispatchLifecycleScopeFactory(coroutineContextFactory: () -> CoroutineContext)

Factory for DispatchLifecycleScopes. This may be injected into a lifecycle-aware class to provide custom CoroutineContexts.

Link copied to clipboard
typealias LifecycleCoroutineScope = DispatchLifecycleScope

Deprecated in favor of DispatchLifecycleScope in order to avoid name collisions with Androidx.

Link copied to clipboard
class ViewLifecycleCoroutineScope : DispatchLifecycleScope

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

Functions

Link copied to clipboard
fun MainImmediateContext(): CoroutineContext

Default implementation of a CoroutineContext as seen in a MainImmediateCoroutineScope.

Link copied to clipboard
suspend fun <T> Lifecycle.onNextCreate(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T?
suspend fun <T> LifecycleOwner.onNextCreate(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T?

Executes block one time, the next time the Lifecycle's state is at least Lifecycle.State.CREATED.

Link copied to clipboard
suspend fun <T> Lifecycle.onNextResume(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T?
suspend fun <T> LifecycleOwner.onNextResume(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T?

Executes block one time, the next time the Lifecycle's state is at least Lifecycle.State.RESUMED.

Link copied to clipboard
suspend fun <T> Lifecycle.onNextStart(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T?
suspend fun <T> LifecycleOwner.onNextStart(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T?

Executes block one time, the next time the Lifecycle's state is at least Lifecycle.State.STARTED.

Link copied to clipboard
@ExperimentalCoroutinesApi
fun CoroutineScope.withViewLifecycle(fragment: Fragment, block: ViewLifecycleCoroutineScope.() -> Unit): Job

CoroutineScope helper for a Fragment's ViewLifecycleOwner.