opensavvy.progress.coroutines¶
Types¶
CoroutineProgressReporter¶
class CoroutineProgressReporter(reporter: ProgressReporter) : AbstractCoroutineContextElement, ProgressReporter
Captures progress information about the currently running task.
StateFlowProgressReporter¶
ProgressReporter implementation which stores the latest progress information in progress, a StateFlow.
Functions¶
captureProgress¶
@ExperimentalProgressApi
fun <Value> captureProgress(block: suspend () -> Value): Flow<Progressive<Value?>>
captureProgress¶
@ExperimentalProgressApi
fun <Value> Flow<Value>.captureProgress(): Flow<Progressive<Value?>>
mapProgressTo¶
suspend fun <R> mapProgressTo(progressInterval: ClosedFloatingPointRange<Double>, block: suspend () -> R): R
Reduces progress events emitted in block to fit into progressInterval.
report¶
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.