StatefulComposable

fun <T : Any> StatefulComposable(state: UiState<T>, onShowSnackbar: suspend (String, SnackbarAction, Throwable?) -> Boolean, content: @Composable (T) -> Unit)(source)

Renders UiState.data, a loading indicator, and an error snackbar callback.

The error is consumed during composition, before the callback completes. Recomposition can cancel an unfinished callback; a replacement error under the same callback key can be consumed without starting another callback. Consumption does not acknowledge successful delivery.

Screens collect their ViewModel state with collectAsStateWithLifecycle and pass it here. See the state-management guide for subscription lifetimes and event-delivery limitations.

Parameters

state

Data, loading flag, and error event to render.

onShowSnackbar

Callback invoked with the error message, REPORT action, and throwable. Its Boolean return value is ignored by this wrapper.

content

Content rendered with the current data, including while loading.

Type Parameters

T

The non-null screen-data type; its properties may be nullable.

See also