Skip to content

report

suspend fun report(progress: Progress)

Reports progress to the progress reporter stored in the currentCoroutineContext.

If there is no progress reporter in the current context, this function does nothing.

Example

suspend fun main() {
    reportProgress(::println) {
        task1()
    }
}

suspend fun task1() {
    report(loading(0.0))
    delay(500)
    report(loading(0.5))
    delay(500)
    report(done())
}
Loading(0%)
Loading(50%)
Done

See also