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

commonMain.com.copperleaf.ballast.test.internal.vm.TestSideJobScope.kt Maven / Gradle / Ivy

There is a newer version: 4.2.1
Show newest version
package com.copperleaf.ballast.test.internal.vm

import com.copperleaf.ballast.BallastLogger
import com.copperleaf.ballast.SideJobScope
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineScope

internal class TestSideJobScope(
    private val sideJobScopeDelegate: SideJobScope, Events, State>,
) : SideJobScope, CoroutineScope by sideJobScopeDelegate {

    override val logger: BallastLogger get() = sideJobScopeDelegate.logger
    override val currentStateWhenStarted: State get() = sideJobScopeDelegate.currentStateWhenStarted
    override val restartState: SideJobScope.RestartState get() = sideJobScopeDelegate.restartState

    override suspend fun postInput(input: Inputs) {
        val deferred = CompletableDeferred()
        sideJobScopeDelegate.postInput(
            TestViewModel.Inputs.ProcessInput(input, deferred)
        )
        deferred.await()
    }

    override suspend fun postEvent(event: Events) {
        sideJobScopeDelegate.postEvent(event)
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy