Success

data class Success<T>(data: T) : Result<T>

Indicates a success state.

Constructors

Success
Link copied to clipboard
fun <T> Success(data: T)

Functions

mapData
Link copied to clipboard
fun <S> mapData(dataMapper: (T) -> S): Result<S>

Maps the type T to type S.

mapError
Link copied to clipboard
fun mapError(mapper: (Throwable) -> Exception): Result<T>
mapToUnit
Link copied to clipboard
fun mapToUnit(): Result<Unit>

Maps the type T to Unit.

onError
Link copied to clipboard
fun onError(callback: (Throwable) -> Unit): Result<T>

Convenience method to listen for Error.

onSuccess
Link copied to clipboard
fun onSuccess(callback: (T) -> Unit): Result<T>

Convenience method to listen for Success.

toString
Link copied to clipboard
open override fun toString(): String

Properties

data
Link copied to clipboard
val data: T

holds the actual result

dataOrNull
Link copied to clipboard
val dataOrNull: T?

Convenience property to directly get the Success.data of T if this Result is a Success or null otherwise.

throwableOrNull
Link copied to clipboard
val throwableOrNull: Throwable?

Convenience property to directly get the Error.throwable if this Result is an Error or null otherwise