This commit is contained in:
2024-05-30 21:41:02 +02:00
parent 03ba14d918
commit ae5c229e4b
32 changed files with 537 additions and 344 deletions

View File

@@ -0,0 +1,36 @@
package eventDemo.libs.command
import kotlin.reflect.KClass
interface CommandStream<C : Command> {
/**
* Send a new [Command] to the queue.
*/
suspend fun send(
type: KClass<C>,
command: C,
)
/**
* Send multiple [Command] to the queue.
*/
suspend fun send(
type: KClass<C>,
vararg commands: C,
) {
commands.forEach { send(type, it) }
}
/**
* A class to implement succes/faild action.
*/
interface ComputeStatus {
fun ack()
fun nack()
}
suspend fun process(block: CommandBlock<C>)
}
suspend inline fun <reified C : Command> CommandStream<C>.send(vararg command: C) = send(C::class, *command)