Package-level declarations
Types
Derived, UI-friendly summary of the device connection lifecycle. Combines ServiceRepository.connectionState with the ServiceRepository.RECONNECTING_PROGRESS_TEXT handshake-recovery signal and expected-restart state. Configuration health is modeled separately so region, lockdown, and managed-mode policy cannot leak into the connection label.
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 Flow via kotlinx.coroutines.flow.asFlow in the ViewModel (hiding hot-flow semantics), 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).