1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

fixes in aggregation of flows

This commit is contained in:
InsanusMokrassar 2020-10-27 15:51:48 +06:00
parent b053c29ea3
commit 37a23c7e79

View File

@ -13,13 +13,12 @@ fun <T> aggregateFlows(
internalBufferSize: Int = 64
): Flow<T> {
val sharedFlow = MutableSharedFlow<T>(extraBufferCapacity = internalBufferSize)
val bc = BroadcastChannel<T>(internalBufferSize)
flows.forEach {
it.onEach {
safely { sharedFlow.emit(it) }
}.launchIn(withScope)
}
return bc.asFlow()
return sharedFlow
}
fun <T> Flow<Iterable<T>>.flatMap(): Flow<T> = flow {