1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 03:58:44 +00:00

add asAction and several variants of oneOf

This commit is contained in:
InsanusMokrassar 2021-01-19 20:18:30 +06:00
parent fc71e028c4
commit 08b8710772

View File

@ -12,10 +12,20 @@ suspend fun <T> BehaviourContext.parallel(
inline infix fun <T, O> Deferred<T>.withAction(noinline callback: suspend (T) -> O) = DeferredAction(this, callback) inline infix fun <T, O> Deferred<T>.withAction(noinline callback: suspend (T) -> O) = DeferredAction(this, callback)
suspend fun <O> BehaviourContext.oneOf( inline fun <T> Deferred<T>.asAction() = DeferredAction(this) { it }
suspend fun <O> BehaviourContext.oneOfActions(
deferredActions: Iterable<DeferredAction<*, O>> deferredActions: Iterable<DeferredAction<*, O>>
) = deferredActions.invokeFirstOf(scope) ) = deferredActions.invokeFirstOf(scope)
suspend fun <O> BehaviourContext.oneOf( suspend fun <O> BehaviourContext.oneOfActions(
vararg deferredActions: DeferredAction<*, O> vararg deferredActions: DeferredAction<*, O>
) = this@oneOfActions.oneOfActions(deferredActions.toList())
suspend fun <O> BehaviourContext.oneOf(
deferredActions: Iterable<Deferred<O>>
) = oneOfActions(deferredActions.map { it.asAction() })
suspend fun <O> BehaviourContext.oneOf(
vararg deferredActions: Deferred<O>
) = oneOf(deferredActions.toList()) ) = oneOf(deferredActions.toList())