AdaptyResult

sealed interface AdaptyResult<out T>

A wrapper class representing the result of an operation.

Parameters

T

The type of the successful result.

Inheritors

Types

Link copied to clipboard
data class Error : AdaptyResult<Nothing>

Represents a failed result containing an AdaptyError.

Link copied to clipboard
data class Success<T> : AdaptyResult<T>

Represents a successful result containing a value of type T.

Properties

Link copied to clipboard

Returns true if this is an AdaptyResult.Error result.

Link copied to clipboard

Returns true if this is a AdaptyResult.Success result.

Functions

Link copied to clipboard

Returns the AdaptyError if this is AdaptyResult.Error, or null if it is AdaptyResult.Success.

Link copied to clipboard
inline fun <T, R> AdaptyResult<T>.fold(onSuccess: (T) -> R, onError: (AdaptyError) -> R): R

Transforms the AdaptyResult into a value of type R using onSuccess if successful or onError if it is an error.

Link copied to clipboard
inline fun <T> AdaptyResult<T>.getOrNull(): T?

Returns the value if this is AdaptyResult.Success, or null if it is AdaptyResult.Error.

Link copied to clipboard
inline fun <T> AdaptyResult<T>.onError(action: (AdaptyError) -> Unit): AdaptyResult<T>

Executes action if this is an AdaptyResult.Error result, then returns the receiver.

Link copied to clipboard
inline fun <T> AdaptyResult<T>.onSuccess(action: (T) -> Unit): AdaptyResult<T>

Executes action if this is a AdaptyResult.Success result, then returns the receiver.