DataState

interface DataState<out R>

DataState Contains three different state:

  • Success : returned data

  • Error : thrown exception

  • Loading : initialize state

Example:

fun main() {
val state: DataState<Int> = DataState.Success(1)
when (state) {
is DataState.Success -> println(state.data)
is DataState.Error -> println(state.exception)
is DataState.Loading -> println("Loading")
}
}

Since

1.3.0

Inheritors

Types

Link copied to clipboard
data class Error(val exception: Exception) : DataState<Nothing>
Link copied to clipboard
data object Loading : DataState<Nothing>
Link copied to clipboard
data class Success<T>(val data: T) : DataState<T>