FirstViewModel

The MVVM androidx.lifecycle.ViewModel for the first screen in the MVVM demo. Delegates image loading to a com.grarcht.shuttle.demo.core.viewmodel.DefaultImageLoader and emits one-shot NavigationEvents when the user requests navigation.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
val uiState: StateFlow<IOResult>

Functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
fun currentImageModel(): ImageModel?

Returns the ImageModel from the last successful load, or null if loading has not completed successfully.

Link copied to clipboard
Link copied to clipboard
fun loadImage(resources: Resources, @RawRes imageId: Int)

Loads the image from imageId in resources. Repeated calls after a successful load are ignored.

Link copied to clipboard

Emits a NavigationEvent.Normally event for the view to execute, carrying the currently loaded image model. Does nothing if no image has been loaded yet.

Link copied to clipboard

Emits a NavigationEvent.WithShuttle event for the view to execute, carrying the currently loaded image model. Does nothing if no image has been loaded yet.