ProgressiveOutcome

sealed class ProgressiveOutcome<out Failure, out Value>(source)

A Outcome with integrated Progress management.

There are three possible cases:

Note that in cases, a progressive outcome may be currently loading.

  • Incomplete must be loading,

  • Success may be loading if the task is currently querying a newer value than the one it stores,

  • Failure may be loading if the task is currently retrying the operation.

To access the inner outcome and progression, you can use the destructuring operator:

val (out, progression) = /* ProgressiveOutcome */

To create progressive outcomes from computations, use the successfulWithProgress and failedWithProgress factories.

Inheritors

Types

Link copied to clipboard
data class Failure<Failure>(val failure: Failure, val progress: Progress = done()) : ProgressiveOutcome<Failure, Nothing> , ProgressiveOutcome.Unsuccessful<Failure>

The latest known result of the operation was a failure, available as failure.

Link copied to clipboard

The operation is ongoing, but we do not know if it will be successful or a failure.

Link copied to clipboard
data class Success<Value>(val value: Value, val progress: Progress = done()) : ProgressiveOutcome<Nothing, Value>

The latest known result of the operation was a success, available as value.

Link copied to clipboard
sealed interface Unsuccessful<out Failure>

Operations that are not successful; common supertype of Incomplete and Failure.

Properties

Link copied to clipboard
Link copied to clipboard

Returns Failure.failure, or null if this outcome is not a failure.

Link copied to clipboard
abstract val progress: Progress

The current progression of this outcome.

Link copied to clipboard
Link copied to clipboard

Returns Success.value, or null if this outcome is not successful.

Functions

Link copied to clipboard

Converts this progressive outcome into a regular outcome.

Link copied to clipboard
Link copied to clipboard
operator fun ProgressiveOutcome<*, *>.component2(): Progress

Syntax sugar for ProgressiveOutcome.progress.

Link copied to clipboard

Replaces the progress information from this progressive outcome.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline fun <Failure> ProgressiveOutcome<Failure, *>.onFailure(block: (Failure) -> Unit)

Executes block if this outcome is a failure.

Link copied to clipboard
inline fun ProgressiveOutcome<*, *>.onIncomplete(block: () -> Unit)

Executes block if this outcome is incomplete.

Link copied to clipboard
inline fun ProgressiveOutcome<*, *>.onLoading(block: (Progress.Loading) -> Unit)

Executes block if this outcome is loading (its ProgressiveOutcome.progress is Progress.Loading).

Link copied to clipboard
inline fun <Value> ProgressiveOutcome<*, Value>.onSuccess(block: (Value) -> Unit)

Executes block if this outcome is successful.

Link copied to clipboard