Api Result
A class that represents a result of an operation.
This class is efficient:
no actual objects are created,
all operations are inlined
no function resolution is performed.
ApiResult is not an Rx-style callback chain - the operators that are invoked are called immediately and in-place.
Functions
Link copied to clipboard
Link copied to clipboard
Get the Success component of this result or null
Link copied to clipboard
Get the Error component of this result or null
Link copied to clipboard
inline fun <T, R : Iterable<T>> ApiResult<R>.errorIfEmpty(exception: () -> Exception = { ConditionNotSatisfiedException("Collection was empty") }): ApiResult<R>
inline fun <T, R : Sequence<T>> ApiResult<R>.errorIfEmpty(exception: () -> Exception = { ConditionNotSatisfiedException("Sequence was empty") }): ApiResult<R>
Makes this an error if the collection is empty.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
infix inline fun <T : Exception, R> ApiResult<R>.recover(another: (e: T) -> ApiResult<R>): ApiResult<R>
Recover from an exception of type R, else no-op. Does not affect Loading.
Recover from an exception. Does not affect Loading See also the typed version of this function to recover from a specific exception type
Link copied to clipboard
Link copied to clipboard
Alias for errorOnNull
Link copied to clipboard