ViewModel

abstract class ViewModel<T : UiState>

Abstract base class for view models managing UI state. Each view model holds a mutable UI state and provides error handling capabilities.

Parameters

T

The type of UI state managed by this view model.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
protected abstract val _uiState: MutableState<T>

The mutable internal UI state.

Link copied to clipboard

Gets the current error state, preferring global errors over screen-specific errors.

Link copied to clipboard

Optional global error state.

Link copied to clipboard
abstract val setGlobalError: (Exception?, ErrorType?) -> Unit

Callback to set a global error.

Link copied to clipboard
val uiState: State<T>

Public read-only access to the UI state.

Functions

Link copied to clipboard
fun setError(error: Exception?, type: ErrorType? = ErrorType.WARNING)

Sets an error on either the global error state or the screen state.