LifecycleResumePauseEffectScope

Receiver scope for LifecycleResumeEffect that offers the onPauseOrDispose clause to couple the ON_RESUME effect. This should be the last statement in any call to LifecycleResumeEffect.

This scope is also a LifecycleOwner to allow access to the (lifecycle)LifecycleResumePauseEffectScope.lifecycle within the onPauseOrDispose clause.

Parameters

lifecycle

The lifecycle being observed by this receiver scope

Constructors

Link copied to clipboard
constructor(lifecycle: Lifecycle)

Properties

Link copied to clipboard
open override val lifecycle: Lifecycle

Functions

Link copied to clipboard
inline fun onPauseOrDispose(crossinline onPauseOrDisposeEffect: LifecycleOwner.() -> Unit): LifecyclePauseOrDisposeEffectResult

Provide the onPauseOrDisposeEffect to the LifecycleResumeEffect to run when the observer receives an (ON_PAUSE)Lifecycle.Event.ON_PAUSE event or must undergo cleanup.

Link copied to clipboard
suspend fun LifecycleOwner.repeatOnLifecycle(state: Lifecycle.State, block: suspend CoroutineScope.() -> Unit)

LifecycleOwner's extension function for Lifecycle.repeatOnLifecycle to allow an easier call to the API from LifecycleOwners such as Activities and Fragments.

Link copied to clipboard
inline suspend fun <R> LifecycleOwner.withCreated(crossinline block: () -> R): R

Run block with this LifecycleOwner's Lifecycle in a Lifecycle.State of at least Lifecycle.State.CREATED and resume with the result. Throws the CancellationException if the lifecycle has reached Lifecycle.State.DESTROYED by the time of the call or before block is able to run.

Link copied to clipboard
inline suspend fun <R> LifecycleOwner.withResumed(crossinline block: () -> R): R

Run block with this LifecycleOwner's Lifecycle in a Lifecycle.State of at least Lifecycle.State.RESUMED and resume with the result. Throws the CancellationException if the lifecycle has reached Lifecycle.State.DESTROYED by the time of the call or before block is able to run.

Link copied to clipboard
inline suspend fun <R> LifecycleOwner.withStarted(crossinline block: () -> R): R

Run block with this LifecycleOwner's Lifecycle in a Lifecycle.State of at least Lifecycle.State.STARTED and resume with the result. Throws the CancellationException if the lifecycle has reached Lifecycle.State.DESTROYED by the time of the call or before block is able to run.

Link copied to clipboard
inline suspend fun <R> LifecycleOwner.withStateAtLeast(state: Lifecycle.State, crossinline block: () -> R): R

Run block with this LifecycleOwner's Lifecycle in a Lifecycle.State of at least state and resume with the result. Throws the CancellationException if the lifecycle has reached Lifecycle.State.DESTROYED by the time of the call or before block is able to run.