Package-level declarations
Types
Derived, UI-friendly summary of the device connection state. Combines ServiceRepository.connectionState with "region unset" to surface the MUST_SET_REGION case that otherwise needs a separate boolean flag in the UI layer.
Shared base for the application-level ViewModel.
Functions
fun <T> Flow<T>.asUiState(stopTimeout: Duration = 5.seconds): StateFlow<UiState<T>>
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.
Creates and returns a MutableSharedFlow intended for one-shot error events. Expose as SharedFlow via asSharedFlow in the ViewModel, and collect in the UI to show snackbars or toasts.
fun safeLaunch(context: CoroutineContext = EmptyCoroutineContext, errorEvents: MutableSharedFlow<UiText>? = null, tag: String? = null, block: suspend CoroutineScope.() -> Unit): Job
Launches a coroutine in viewModelScope that catches all exceptions except CancellationException. Non-cancellation errors are logged and emitted to errorEvents (if provided) for one-shot UI consumption (e.g. snackbar / toast).