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

commonMain.dev.inmo.tgbotapi.extensions.behaviour_builder.Variants.kt Maven / Gradle / Ivy

There is a newer version: 20.0.1
Show newest version
package dev.inmo.tgbotapi.extensions.behaviour_builder

import dev.inmo.micro_utils.coroutines.DeferredAction
import dev.inmo.micro_utils.coroutines.invokeFirstOf
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async

suspend fun  BehaviourContext.parallel(
    action: BehaviourContextReceiver
) = async {
    action()
}

inline infix fun  Deferred.withAction(noinline callback: suspend (T) -> O) = DeferredAction(this, callback)

inline fun  Deferred.asAction() = DeferredAction(this) { it }

suspend fun  BehaviourContext.oneOfActions(
    deferredActions: Iterable>
) = deferredActions.invokeFirstOf(scope)

suspend fun  BehaviourContext.oneOfActions(
    vararg deferredActions: DeferredAction<*, O>
) = [email protected](deferredActions.toList())

suspend fun  BehaviourContext.oneOf(
    deferredActions: Iterable>
) = oneOfActions(deferredActions.map { it.asAction() })

suspend fun  BehaviourContext.oneOf(
    vararg deferredActions: Deferred
) = oneOf(deferredActions.toList())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy