1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-02 14:49:47 +00:00

fill changelog and add kdocs for firstOf

This commit is contained in:
2025-08-11 15:50:06 +06:00
parent 2182e44bc2
commit 4dd9740fec
2 changed files with 19 additions and 0 deletions

View File

@@ -2,6 +2,13 @@
## 28.0.0
* `Core`:
* Add `firstOf` extension
* `BehaviourBuilder`:
* All builders for behaviours got boolean `useDefaultSubcontextInitialAction`
* Add opportunity to pass `BehaviourContextData` in `DefaultBehaviourContext` constructor and `copy` method
* By default, commands to other bots will be ignored in triggers and waiters
## 27.1.2
* `Core`:

View File

@@ -3,6 +3,18 @@ package dev.inmo.tgbotapi.utils
import dev.inmo.micro_utils.coroutines.firstOf
import kotlinx.coroutines.CoroutineScope
/**
* Launches all provided suspending [deferreds] in this [CoroutineScope] and returns the value
* produced by the first block that completes.
*
* - Provide at least one block; otherwise the call will never complete.
* - Cancellation and error propagation semantics are delegated to the underlying
* dev.inmo.micro_utils.coroutines.firstOf implementation.
*
* @param T The type of the resulting value.
* @param deferreds The suspending blocks to race; they are started eagerly.
* @return The result produced by the first completed block.
*/
suspend fun <T> CoroutineScope.firstOf(
vararg deferreds: suspend () -> T
): T = firstOf {