Skip to content

Commit

Permalink
Promote the following experimental API to stable (#2971)
Browse files Browse the repository at this point in the history
* transformWhile
* awaitClose and ProducerScope (for callbackFlow and channelFlow)
* merge
* runningFold, runningReduce, and scan
  • Loading branch information
qwwdfsad committed Oct 11, 2021
1 parent 5a62781 commit 8d1ee7d
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 13 deletions.
8 changes: 2 additions & 6 deletions kotlinx-coroutines-core/common/src/channels/Produce.kt
Expand Up @@ -6,14 +6,11 @@ package kotlinx.coroutines.channels

import kotlinx.coroutines.*
import kotlin.coroutines.*
import kotlinx.coroutines.flow.*

/**
* Scope for the [produce][CoroutineScope.produce] coroutine builder.
*
* **Note: This is an experimental api.** Behavior of producers that work as children in a parent scope with respect
* to cancellation and error handling may change in the future.
* Scope for the [produce][CoroutineScope.produce], [callbackFlow] and [channelFlow] builders.
*/
@ExperimentalCoroutinesApi
public interface ProducerScope<in E> : CoroutineScope, SendChannel<E> {
/**
* A reference to the channel this coroutine [sends][send] elements to.
Expand Down Expand Up @@ -45,7 +42,6 @@ public interface ProducerScope<in E> : CoroutineScope, SendChannel<E> {
* }
* ```
*/
@ExperimentalCoroutinesApi
public suspend fun ProducerScope<*>.awaitClose(block: () -> Unit = {}) {
check(kotlin.coroutines.coroutineContext[Job] === this) { "awaitClose() can only be invoked from the producer context" }
try {
Expand Down
1 change: 0 additions & 1 deletion kotlinx-coroutines-core/common/src/flow/operators/Limit.kt
Expand Up @@ -112,7 +112,6 @@ public fun <T> Flow<T>.takeWhile(predicate: suspend (T) -> Boolean): Flow<T> = f
* }
* ```
*/
@ExperimentalCoroutinesApi
public fun <T, R> Flow<T>.transformWhile(
@BuilderInference transform: suspend FlowCollector<R>.(value: T) -> Boolean
): Flow<R> =
Expand Down
2 changes: 0 additions & 2 deletions kotlinx-coroutines-core/common/src/flow/operators/Merge.kt
Expand Up @@ -90,7 +90,6 @@ public fun <T> Flow<Flow<T>>.flattenConcat(): Flow<T> = flow {
* Applications of [flowOn], [buffer], and [produceIn] _after_ this operator are fused with
* its concurrent merging so that only one properly configured channel is used for execution of merging logic.
*/
@ExperimentalCoroutinesApi
public fun <T> Iterable<Flow<T>>.merge(): Flow<T> {
/*
* This is a fuseable implementation of the following operator:
Expand All @@ -114,7 +113,6 @@ public fun <T> Iterable<Flow<T>>.merge(): Flow<T> {
* Applications of [flowOn], [buffer], and [produceIn] _after_ this operator are fused with
* its concurrent merging so that only one properly configured channel is used for execution of merging logic.
*/
@ExperimentalCoroutinesApi
public fun <T> merge(vararg flows: Flow<T>): Flow<T> = flows.asIterable().merge()

/**
Expand Down
Expand Up @@ -85,7 +85,6 @@ public fun <T> Flow<T>.onEach(action: suspend (T) -> Unit): Flow<T> = transform
*
* This function is an alias to [runningFold] operator.
*/
@ExperimentalCoroutinesApi
public fun <T, R> Flow<T>.scan(initial: R, @BuilderInference operation: suspend (accumulator: R, value: T) -> R): Flow<R> = runningFold(initial, operation)

/**
Expand All @@ -97,7 +96,6 @@ public fun <T, R> Flow<T>.scan(initial: R, @BuilderInference operation: suspend
* ```
* will produce `[], [1], [1, 2], [1, 2, 3]]`.
*/
@ExperimentalCoroutinesApi
public fun <T, R> Flow<T>.runningFold(initial: R, @BuilderInference operation: suspend (accumulator: R, value: T) -> R): Flow<R> = flow {
var accumulator: R = initial
emit(accumulator)
Expand All @@ -118,7 +116,6 @@ public fun <T, R> Flow<T>.runningFold(initial: R, @BuilderInference operation: s
* ```
* will produce `[1, 3, 6, 10]`
*/
@ExperimentalCoroutinesApi
public fun <T> Flow<T>.runningReduce(operation: suspend (accumulator: T, value: T) -> T): Flow<T> = flow {
var accumulator: Any? = NULL
collect { value ->
Expand Down
1 change: 0 additions & 1 deletion reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt
Expand Up @@ -4,7 +4,6 @@

package kotlinx.coroutines.reactor

import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlin.coroutines.*
import kotlinx.coroutines.reactive.*
import reactor.util.context.*
Expand Down

0 comments on commit 8d1ee7d

Please sign in to comment.