asUiState

context(viewModel: ViewModel)
fun <T> Flow<T>.asUiState(stopTimeout: Duration = 5.seconds): StateFlow<UiState<T>>(source)

Wraps this Flow into a StateFlow<UiState<T>>, emitting UiState.Loading until the first value, then UiState.Content for each emission. Upstream errors are caught and mapped to UiState.Error.