WithLifecycleStateKt

Added in 2.3.0

public final class WithLifecycleStateKt


Summary

Public methods

static final @NonNull R
<R extends Object> withCreated(
    @NonNull Lifecycle receiver,
    @NonNull Function0<@NonNull R> block
)

Run block with this Lifecycle in a Lifecycle.State of at least Lifecycle.State.CREATED and resume with the result.

static final @NonNull R
<R extends Object> withCreated(
    @NonNull LifecycleOwner receiver,
    @NonNull Function0<@NonNull R> block
)

Run block with this LifecycleOwner's Lifecycle in a Lifecycle.State of at least Lifecycle.State.CREATED and resume with the result.

static final @NonNull R
<R extends Object> withResumed(
    @NonNull Lifecycle receiver,
    @NonNull Function0<@NonNull R> block
)

Run block with this Lifecycle in a Lifecycle.State of at least Lifecycle.State.RESUMED and resume with the result.

static final @NonNull R
<R extends Object> withResumed(
    @NonNull LifecycleOwner receiver,
    @NonNull Function0<@NonNull R> block
)

Run block with this LifecycleOwner's Lifecycle in a Lifecycle.State of at least Lifecycle.State.RESUMED and resume with the result.

static final @NonNull R
<R extends Object> withStarted(
    @NonNull Lifecycle receiver,
    @NonNull Function0<@NonNull R> block
)

Run block with this Lifecycle in a Lifecycle.State of at least Lifecycle.State.STARTED and resume with the result.

static final @NonNull R
<R extends Object> withStarted(
    @NonNull LifecycleOwner receiver,
    @NonNull Function0<@NonNull R> block
)

Run block with this LifecycleOwner's Lifecycle in a Lifecycle.State of at least Lifecycle.State.STARTED and resume with the result.

static final @NonNull R
<R extends Object> withStateAtLeast(
    @NonNull Lifecycle receiver,
    @NonNull Lifecycle.State state,
    @NonNull Function0<@NonNull R> block
)

Run block with this Lifecycle in a Lifecycle.State of at least state and resume with the result.

static final @NonNull R
<R extends Object> withStateAtLeast(
    @NonNull LifecycleOwner receiver,
    @NonNull Lifecycle.State state,
    @NonNull Function0<@NonNull R> block
)

Run block with this LifecycleOwner's Lifecycle in a Lifecycle.State of at least state and resume with the result.

Public methods

public static final @NonNull R <R extends Object> withCreated(
    @NonNull Lifecycle receiver,
    @NonNull Function0<@NonNull R> block
)

Run block with this 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.

public static final @NonNull R <R extends Object> withCreated(
    @NonNull LifecycleOwner receiver,
    @NonNull Function0<@NonNull R> block
)

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.

public static final @NonNull R <R extends Object> withResumed(
    @NonNull Lifecycle receiver,
    @NonNull Function0<@NonNull R> block
)

Run block with this 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.

public static final @NonNull R <R extends Object> withResumed(
    @NonNull LifecycleOwner receiver,
    @NonNull Function0<@NonNull R> block
)

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.

public static final @NonNull R <R extends Object> withStarted(
    @NonNull Lifecycle receiver,
    @NonNull Function0<@NonNull R> block
)

Run block with this 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.

public static final @NonNull R <R extends Object> withStarted(
    @NonNull LifecycleOwner receiver,
    @NonNull Function0<@NonNull R> block
)

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.

public static final @NonNull R <R extends Object> withStateAtLeast(
    @NonNull Lifecycle receiver,
    @NonNull Lifecycle.State state,
    @NonNull Function0<@NonNull R> block
)

Run block with this 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.

public static final @NonNull R <R extends Object> withStateAtLeast(
    @NonNull LifecycleOwner receiver,
    @NonNull Lifecycle.State state,
    @NonNull Function0<@NonNull R> block
)

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.