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

commonMain.com.copperleaf.ballast.test.internal.vm.ViewModelWrapper.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.BallastViewModel
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.channels.ChannelResult
import kotlinx.coroutines.flow.StateFlow

internal class ViewModelWrapper(
    private val delegate: BallastViewModel, Events, State>,
) : BallastViewModel {

    override val name: String
        get() = delegate.name
    override val type: String
        get() = delegate.type

    override suspend fun send(element: Inputs) {
        delegate.send(TestViewModel.Inputs.ProcessInput(element, CompletableDeferred()))
    }

    override suspend fun sendAndAwaitCompletion(element: Inputs) {
        delegate.sendAndAwaitCompletion(TestViewModel.Inputs.ProcessInput(element, CompletableDeferred()))
    }

    override fun trySend(element: Inputs): ChannelResult {
        return delegate.trySend(TestViewModel.Inputs.ProcessInput(element, CompletableDeferred()))
    }

    override fun observeStates(): StateFlow {
        return delegate.observeStates()
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy