Skip to content

Commit

Permalink
Clarify behavior of produceIn. (Kotlin#2976)
Browse files Browse the repository at this point in the history
The previous wording said "thus resulting channel should be properly closed or cancelled," but it wasn't really clear what that meant -- whether the caller needed to close it or cancel it, or whether it would be properly closed by the implementation.
  • Loading branch information
lowasser committed Oct 12, 2021
1 parent bf41f21 commit 5e870c1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kotlinx-coroutines-core/common/src/flow/Channels.kt
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ public fun <T> Flow<T>.broadcastIn(
* Creates a [produce] coroutine that collects the given flow.
*
* This transformation is **stateful**, it launches a [produce] coroutine
* that collects the given flow and thus resulting channel should be properly closed or cancelled.
* that collects the given flow, and has the same behavior:
*
* * if collecting the flow throws, the channel will be closed with that exception
* * if the [ReceiveChannel] is cancelled, the collection of the flow will be cancelled
* * if collecting the flow completes normally, the [ReceiveChannel] will be closed normally
*
* A channel with [default][Channel.Factory.BUFFERED] buffer size is created.
* Use [buffer] operator on the flow before calling `produceIn` to specify a value other than
Expand Down

0 comments on commit 5e870c1

Please sign in to comment.