LoadingProgress
Represents progress within a loading operation.
This sealed class hierarchy provides type-safe progress events that can be collected via Kotlin Flow. Designed for use with coroutines - no 3rd party reactive libraries required.
Usage:
loader.progress.collect { progress ->
when (progress) {
is LoadingProgress.Started -> println("Loading started")
is LoadingProgress.StageStarted -> println("Stage: ${progress.stage.name}")
is LoadingProgress.StageProgress -> updateProgressBar(progress.progress)
is LoadingProgress.StageCompleted -> println("Done: ${progress.stage.name}")
is LoadingProgress.Completed -> println("All done!")
is LoadingProgress.Failed -> println("Error: ${progress.message}")
}
}Content copied to clipboard
Inheritors
Types
Link copied to clipboard
Overall loading completed successfully.
Link copied to clipboard
data class Failed(val stage: LoadingStage?, val error: Throwable, val message: String) : LoadingProgress
Loading failed with an error.
Link copied to clipboard
A stage has completed.
Link copied to clipboard
data class StageProgress(val stage: LoadingStage, val progress: Float, val bytesProcessed: Long? = null, val totalBytes: Long? = null, val itemsProcessed: Int? = null, val totalItems: Int? = null, val message: String? = null) : LoadingProgress
Progress within the current stage.
Link copied to clipboard
A new stage has begun.
Link copied to clipboard
Loading has started.