mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-06-27 05:35:13 +00:00
Compare commits
2 Commits
df512a917b
...
v29.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d97d10ee1 | |||
| 4b7d052ece |
@@ -2,6 +2,14 @@
|
||||
|
||||
## 29.0.0
|
||||
|
||||
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 9.2](https://core.telegram.org/bots/api-changelog#august-15-2025)**
|
||||
|
||||
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
||||
|
||||
* `Core`:
|
||||
* Add function `firstOfOrNull(vararg suspend () -> T): T?`
|
||||
* Change logic of `firstOf` - now it works based on merged flows and __do not require__ `CoroutineScope` as receiver
|
||||
|
||||
## 28.0.3
|
||||
|
||||
* `Core`:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# TelegramBotAPI [](https://central.sonatype.com/artifact/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#july-3-2025)
|
||||
# TelegramBotAPI [](https://central.sonatype.com/artifact/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#august-15-2025)
|
||||
|
||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
||||
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.merge
|
||||
@@ -53,5 +54,16 @@ suspend fun <T> firstOfOrNull(
|
||||
suspend fun <T> firstOf(
|
||||
vararg deferreds: suspend () -> T
|
||||
): T {
|
||||
return firstOfOrNull(*deferreds) ?: error("Unable to get result of deferreds")
|
||||
val resultFlow = deferreds.map {
|
||||
flow {
|
||||
runCatching {
|
||||
it()
|
||||
}.onSuccess {
|
||||
emit(it)
|
||||
}.onFailure {
|
||||
if (it is CancellationException) throw it
|
||||
}
|
||||
}
|
||||
}.merge()
|
||||
return resultFlow.first()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user