Request

@Composable
fun <T> Request(state: ApiState<T>, onUnauthorized: () -> Unit, loadingContent: @Composable () -> Unit, errorContent: @Composable (Issue) -> Unit, successContent: @Composable (T) -> Unit)

A basic composable for rendering API states, serving to wrap your own UI logic within successContent. The recommendation for its usage would be to wrap it with reasonable defaults according to your own application, as detailed in each parameter.

Parameters

state

The API state to render. This value can be obtained from a xyz.malefic.koven.state.produceApiState call.

onUnauthorized

A callback to be invoked when an unauthorized error is encountered. This is typically used to redirect the user to a login page.

loadingContent

A composable to render while the API request is loading. This is typically something simple like a Spinner.

errorContent

A composable to render when an error is encountered.

successContent

A composable to render when the API request is successful.