All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.report.MapProgressReporter.kt Maven / Gradle / Ivy

package opensavvy.progress.report

import opensavvy.progress.Progress

private class MapProgressReporter(
    private val upstream: ProgressReporter,
    private val transform: (Progress) -> Progress,
) : ProgressReporter {

    override fun report(progress: Progress) {
        upstream.report(transform(progress))
    }

    override fun toString() = "$upstream.map()"
}

/**
 * Creates a new reporter that applies [transform] to each progress event it receives.
 */
fun ProgressReporter.map(transform: (Progress) -> Progress): ProgressReporter =
    MapProgressReporter(this, transform)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy