ItemViewModel
ViewModel for the create/edit item screen, managing Jetpack library creation and updates.
This ViewModel handles both creating new Jetpack items and editing existing ones. It uses SavedStateHandle to retrieve the optional item ID from navigation arguments. If an ID is present, the screen operates in edit mode; otherwise, it creates a new item with a generated UUID.
The ViewModel demonstrates:
Navigation argument handling via SavedStateHandle.toRoute
Form state management with updateState for field updates
Navigation events using OneTimeEvent to trigger back navigation after save
Async operations with updateStateWith for create/update operations
Parameters
Repository providing Jetpack data operations.
Navigation state containing optional item ID from route.
See also
Immutable data class representing form state
State wrapper with loading and error handling
Extension function for synchronous state updates
Extension function for async operations with state updates
Ensures navigation events are consumed only once
Data layer interface for home screen operations