Companion

object Companion

Functions

Link copied to clipboard

Create an error ApiResult value

Link copied to clipboard
@JvmName(name = "flowWithResult")
inline fun <T> ApiResult.Companion.flow(crossinline result: suspend () -> ApiResult<T>): Flow<ApiResult<T>>

Emits ApiResult.Loading, then executes result

Link copied to clipboard
inline operator fun invoke(): ApiResult<Unit>

Returns an ApiResult value. Use this for applying operators such as require and mapWrapping to build chains of operators that should start with an empty value.

inline operator fun <T> invoke(value: T): ApiResult<T>

Create an ApiResult instance using the given value. When value is an Exception, an error result will be created. Otherwise, a success result will be created.

inline operator fun <T> invoke(call: () -> T): ApiResult<T>

Execute call, catching any exceptions, and wrap it in an ApiResult.

Link copied to clipboard
fun <T> Loading(): ApiResult<T>

Create a loading ApiResult value

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

Create a successful ApiResult value

Link copied to clipboard
inline fun <T> ApiResult.Companion.tryFlow(crossinline call: suspend () -> T): Flow<ApiResult<T>>

Emits ApiResult.Loading, then executes call and wraps it.