Is there any reason that `channelFlow` doesn't exp...
# coroutines
k
Is there any reason that
channelFlow
doesn't expose something like
fun channelFlow(buffer: Int = ...)
And instead we have to call
.buffer
downstream?
👀 1
z
It would be confusing to have code that looks like:
Copy code
channelFlow(buffer = UNLIMITED) {
  …
}.conflate()
Because the two buffer specifications would compete (since the operators are fused under the hood and use a single channel), and only one of the specifications would actually be used.
k
The missing piece I had was that operators are fused.
knowing that solves this question
here's the bit in question
Copy code
return if (this is ChannelFlow)
        update(capacity = capacity)
    else
        ChannelFlowOperatorImpl(this, capacity = capacity)
👍 1
and from the docs for anyone who reads this later
Adjacent applications of channelFlow, flowOn, buffer, produceIn, and broadcastIn are always fused so that only one properly configured channel is used for execution.
👍 2