commonMain.com.zegreatrob.testmints.action.ActionCannon.kt Maven / Gradle / Ivy
package com.zegreatrob.testmints.action
import com.zegreatrob.testmints.action.async.SuspendAction
interface ActionCannon {
suspend fun fire(action: SuspendAction): R
companion object {
operator fun invoke(dispatcher: D, pipe: ActionPipe = ActionPipe): ActionCannon =
DispatcherPipeCannon(dispatcher, pipe)
}
}
data class DispatcherPipeCannon(val dispatcher: D, val pipe: ActionPipe = ActionPipe) : ActionCannon {
override suspend fun fire(action: SuspendAction): R = pipe.execute(dispatcher, action)
}