updateState

inline fun <T : Any> MutableStateFlow<UiState<T>>.updateState(update: T.() -> T)(source)

Replaces UiState.data synchronously, preserving loading and the existing error event.

For example, an Item form updates a field with updateState { copy(jetpackName = name) }. The transform runs through MutableStateFlow.update and may be evaluated more than once under contention, so keep it free of side effects. Exceptions propagate to the caller.

Parameters

update

Transform receiving current data and returning its replacement.

Type Parameters

T

The screen-data type.

See also