LoadingProgress

sealed class LoadingProgress(source)

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}")
}
}

Inheritors

Types

Link copied to clipboard
data class Completed(val totalDurationMs: Long, val summary: String? = null) : LoadingProgress

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
data class StageCompleted(val stage: LoadingStage, val durationMs: Long) : LoadingProgress

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
data class StageStarted(val stage: LoadingStage, val description: String? = null) : LoadingProgress

A new stage has begun.

Link copied to clipboard
data class Started(val totalStages: Int, val description: String? = null) : LoadingProgress

Loading has started.