David Bieregger
11/08/2025, 5:47 PMcapacity and onBufferOverflow is not exposed in channelFlow ? Following usecase:
suspend fun receiveOutgoingTransactionsAsFlow(capacity: Int): Flow<EventTransaction> = channelFlow(capacity = capacity /* this parameter doesn't exist */) {
launch {
sharedFlow.collect { item ->
trySend(item).getOrElse {
close(Error("Private buffer of size $capacity overflowed."))
}
}
}
}
This logic ensures that subscribers of a SharedFlow can process independently, but also accounts for the fact that the collector might be too slow. The capacity parameter would be really useful in this case or am I overcomplicating things?mbonnin
11/08/2025, 6:07 PMAdjacent applications of channelFlow, flowOn, buffer, and produceIn are always fused so that only one properly configured channel is used for execution
https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/channel-flow.htmlmbonnin
11/08/2025, 6:08 PM.buffer() on the resulting flowDavid Bieregger
11/08/2025, 6:12 PMchannel. . This means I didn't create another channel and therefore I see no contradiction to this statement.
Unfortunately .buffer() doesn't allow me to handle the buffer overflow myself.ross_a
11/10/2025, 9:15 AMonUndeliveredElement with DROP_LATESTross_a
11/10/2025, 9:16 AMross_a
11/10/2025, 9:16 AM