mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
fixes in aggregation of flows
This commit is contained in:
parent
b053c29ea3
commit
37a23c7e79
@ -13,13 +13,12 @@ fun <T> aggregateFlows(
|
|||||||
internalBufferSize: Int = 64
|
internalBufferSize: Int = 64
|
||||||
): Flow<T> {
|
): Flow<T> {
|
||||||
val sharedFlow = MutableSharedFlow<T>(extraBufferCapacity = internalBufferSize)
|
val sharedFlow = MutableSharedFlow<T>(extraBufferCapacity = internalBufferSize)
|
||||||
val bc = BroadcastChannel<T>(internalBufferSize)
|
|
||||||
flows.forEach {
|
flows.forEach {
|
||||||
it.onEach {
|
it.onEach {
|
||||||
safely { sharedFlow.emit(it) }
|
safely { sharedFlow.emit(it) }
|
||||||
}.launchIn(withScope)
|
}.launchIn(withScope)
|
||||||
}
|
}
|
||||||
return bc.asFlow()
|
return sharedFlow
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> Flow<Iterable<T>>.flatMap(): Flow<T> = flow {
|
fun <T> Flow<Iterable<T>>.flatMap(): Flow<T> = flow {
|
||||||
|
Loading…
Reference in New Issue
Block a user