Skip to content

Commit 5a6aa6c

Browse files
committed
Clarify possible replacement of onCompletion parameter in produce
Fixes #994
1 parent fdcd361 commit 5a6aa6c

File tree

1 file changed

+10
-2
lines changed
  • kotlinx-coroutines-core/common/src/channels

1 file changed

+10
-2
lines changed

kotlinx-coroutines-core/common/src/channels/Produce.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,16 @@ public fun <E> CoroutineScope.produce(
100100
}
101101

102102
/**
103-
* @suppress **This an internal API and should not be used from general code.**
104-
* onCompletion parameter will be redesigned.
103+
* This an internal API and should not be used from general code.**
104+
* onCompletion parameter will be redesigned.
105+
* If you have to use `onCompletion` operator, please report to https://github.com/Kotlin/kotlinx.coroutines/issues/.
106+
* As a temporary solution, [invokeOnCompletion][Job.invokeOnCompletion] can be used instead:
107+
* ```
108+
* fun <E> ReceiveChannel<E>.myOperator(): ReceiveChannel<E> = GlobalScope.produce(Dispatchers.Unconfined) {
109+
* coroutineContext[Job]?.invokeOnCompletion { consumes() }
110+
* }
111+
* ```
112+
* @suppress
105113
*/
106114
@InternalCoroutinesApi
107115
public fun <E> CoroutineScope.produce(

0 commit comments

Comments
 (0)