UiState

sealed interface UiState<out T>(source)

Lightweight tri-state wrapper for UI data. Prefer this over bare nullable initial values when the UI needs to distinguish "still loading" from "genuinely empty."

Inheritors

Types

Link copied to clipboard
data class Content<T>(val data: T) : UiState<T>

Data is available.

Link copied to clipboard
data class Error(val message: UiText) : UiState<Nothing>

An error occurred while loading.

Link copied to clipboard
data object Loading : UiState<Nothing>

Data has not yet arrived.

Functions

Link copied to clipboard
fun <T> UiState<T>.dataOrNull(): T?

Returns the Content data, or null if this state is Loading or Error.