Skip to content

A helper library for representing the state of a request

License

Notifications You must be signed in to change notification settings

ComposeComponents/RequestState

Repository files navigation

RequestState

Build Lint

A helper library for representing the state of a request.

Installation

Stable Preview

implementation "cl.emilym.compose:requeststate:<latest>"

Usage

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)
}

About

A helper library for representing the state of a request

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors