Skip to content

opensavvy.progress.coroutines

Types

CoroutineProgressReporter

Captures progress information about the currently running task.

StateFlowProgressReporter

ProgressReporter implementation which stores the latest progress information in progress, a StateFlow.

Functions

captureProgress

Captures calls to report within block and reports them as a Flow.

captureProgress

Captures calls to report within the given flow and reports them as a new Flow.

mapProgressTo

suspend fun <R> mapProgressTo(progressInterval: ClosedFloatingPointRange<Double>, block: suspend () -> R): R

Reduces progress events emitted in block to fit into progressInterval.

report

suspend fun report(progress: Progress)

Reports progress to the progress reporter stored in the currentCoroutineContext.

reportProgress

suspend fun reportProgress(onProgress: (Progress) -> Unit, block: suspend () -> Unit)

Captures all calls to report in block and transmits them to onProgress.

transformProgress

suspend fun <R> transformProgress(createChildReporter: (ProgressReporter) -> ProgressReporter, block: suspend () -> R): R

Passes the current ProgressReporter to createChildReporter to create a new child reporter of the current coroutine, and adds it to block's context.