Skip to content

Success

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.

If progress is loading, this means the operation has been retried in an attempt to access a more up-to-date version.

Constructors

Success

constructor(value: Value, progress: Progress = done())

Properties

failure

failureOrNull

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

progress

open override val progress: Progress

The current progression of this outcome.

For more information, see ProgressiveOutcome.

value

val value: Value

value

valueOrNull

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

Functions

asOutcome

Converts this progressive outcome into a regular outcome.

Because regular outcomes do not have a concept of progression, the progress information is lost. To access both the outcome and the progression information, consider using destructuration instead:

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

component1

component2

operator fun ProgressiveOutcome<*, *>.component2(): Progress

Syntax sugar for ProgressiveOutcome.progress.

copy

Replaces the progress information from this progressive outcome.

explode

Converts a ProgressiveOutcome into a Progressive.

In the case where in the input ProgressiveOutcome is Incomplete, null is returned.

See also

map

If this outcome is successful, replaces its value using transform.

If this outcome isn't successful, does nothing.

See also

  • mapFailure: Map the failure state instead of the success state.

mapFailure

If this outcome is failed, replaces its failure using transformFailure.

If this outcome isn't failed, does nothing.

See also

  • map: Map the success state instead of the failure state.

onFailure

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

Executes block if this outcome is a failure.

Otherwise, does nothing.

onIncomplete

inline fun ProgressiveOutcome<*, *>.onIncomplete(block: () -> Unit)

Executes block if this outcome is incomplete.

Otherwise, does nothing.

onLoading

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

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

Note that this isn't synonymous with this outcome being in the Incomplete state: successful or failed outcomes may still be loading. For more information, see ProgressiveOutcome.

Otherwise, does nothing.

onSuccess

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

Executes block if this outcome is successful.

Otherwise, does nothing.

toEither