Outcome¶
The result of an operation.
To store progress information as well as the result of the operation, please see ProgressiveOutcome.
There are two possible cases:
-
Successif a successful result is available (seeSuccess.value), -
Failureif a failed result is available (seeFailure.failure).
To create outcomes from computations, use the successful and failed factories.
Arrow¶
Outcome is essentially identical to Arrow's Either. When using Arrow, we recommend using Either most of the time because of all the convenience functions and DSLs it has. Using our companion library state-arrow, it is possible to use Outcome in the Raise DSL.
Because of this, we will keep Outcome as simple as possible, and avoid adding too much sugar.
Inheritors¶
Types¶
Failure¶
The latest known result of the operation was a failure, available as failure.
Success¶
The latest known result of the operation was a success, available as value.
Properties¶
failure¶
failureOrNull¶
Returns Failure.failure, or null if this outcome is not a failure.
value¶
valueOrNull¶
Returns Success.value, or null if this outcome is not successful.
Functions¶
map¶
inline fun <Failure, InputValue, OutputValue> Outcome<Failure, InputValue>.map(transform: (InputValue) -> OutputValue): Outcome<Failure, OutputValue>
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¶
inline fun <InputFailure, Value, OutputFailure> Outcome<InputFailure, Value>.mapFailure(transformFailure: (InputFailure) -> OutputFailure): Outcome<OutputFailure, Value>
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¶
onSuccess¶
Executes block if this outcome is successful.
Otherwise, does nothing.
toEither¶
withProgress¶
fun <Failure, Value> Outcome<Failure, Value>.withProgress(progress: Progress = done()): ProgressiveOutcome<Failure, Value>
Adds progress information to this outcome to make it a ProgressiveOutcome.