LifecycleStartStopEffectScope

Receiver scope for LifecycleStartEffect that offers the onStopOrDispose clause to couple the ON_START effect. This should be the last statement in any call to LifecycleStartEffect.

This scope is also a LifecycleOwner to allow access to the (lifecycle)LifecycleStartStopEffectScope.lifecycle within the onStopOrDispose 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 onStopOrDispose(crossinline onStopOrDisposeEffect: LifecycleOwner.() -> Unit): LifecycleStopOrDisposeEffectResult

Provide the onStopOrDisposeEffect to the LifecycleStartEffect to run when the observer receives an (ON_STOP)Lifecycle.Event.ON_STOP 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.