A helper library for representing the state of a request.
implementation "cl.emilym.compose:requeststate:<latest>"
val data = MutableLiveData<RequestState<String>>()
// The .handle extension function automatically updates the data state based on whether the
// request failed
data.handle {
loadString()
}
// Set a state directly
data.value = RequestState.Success("test")data could then be unwrapped in a composable view:
RequestStateWidget(
data,
retry = { /* retry the operation */ }
) { -> data
Text(data)
}