Skip to content

Commit c3b7b20

Browse files
authored
Promote @FlowPreview API to stable/experimental (#3548)
* Promote @FlowPreview-marked API to stable * Promote @FlowPreview to @experimental where appropriate * Delay-related operators are not promoted as they are clearly underdesigned * Promote AbstractFlow * Promote flat* related operators to gather more feedback and to work on them incrementally later in 1.7+ Fixes #3542 Fixes #3097
1 parent 67e21b2 commit c3b7b20

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

kotlinx-coroutines-core/common/src/flow/Builders.kt

-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ private class SafeFlow<T>(private val block: suspend FlowCollector<T>.() -> Unit
6565
/**
6666
* Creates a _cold_ flow that produces a single value from the given functional type.
6767
*/
68-
@FlowPreview
6968
public fun <T> (() -> T).asFlow(): Flow<T> = flow {
7069
emit(invoke())
7170
}
@@ -80,7 +79,6 @@ public fun <T> (() -> T).asFlow(): Flow<T> = flow {
8079
* fun remoteCallFlow(): Flow<R> = ::remoteCall.asFlow()
8180
* ```
8281
*/
83-
@FlowPreview
8482
public fun <T> (suspend () -> T).asFlow(): Flow<T> = flow {
8583
emit(invoke())
8684
}

kotlinx-coroutines-core/common/src/flow/Channels.kt

-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ public fun <T> BroadcastChannel<T>.asFlow(): Flow<T> = flow {
168168
* default and to control what happens when data is produced faster than it is consumed,
169169
* that is to control backpressure behavior.
170170
*/
171-
@FlowPreview
172171
public fun <T> Flow<T>.produceIn(
173172
scope: CoroutineScope
174173
): ReceiveChannel<T> =

kotlinx-coroutines-core/common/src/flow/Flow.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public interface Flow<out T> {
221221
* }
222222
* ```
223223
*/
224-
@FlowPreview
224+
@ExperimentalCoroutinesApi
225225
public abstract class AbstractFlow<T> : Flow<T>, CancellableFlow<T> {
226226

227227
public final override suspend fun collect(collector: FlowCollector<T>) {

kotlinx-coroutines-core/common/src/flow/operators/Merge.kt

+8-5
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ import kotlinx.coroutines.flow.internal.unsafeFlow as flow
1717

1818
/**
1919
* Name of the property that defines the value of [DEFAULT_CONCURRENCY].
20+
* This is a preview API and can be changed in a backwards-incompatible manner within a single release.
2021
*/
2122
@FlowPreview
2223
public const val DEFAULT_CONCURRENCY_PROPERTY_NAME: String = "kotlinx.coroutines.flow.defaultConcurrency"
2324

2425
/**
2526
* Default concurrency limit that is used by [flattenMerge] and [flatMapMerge] operators.
2627
* It is 16 by default and can be changed on JVM using [DEFAULT_CONCURRENCY_PROPERTY_NAME] property.
28+
* This is a preview API and can be changed in a backwards-incompatible manner within a single release.
2729
*/
2830
@FlowPreview
29-
public val DEFAULT_CONCURRENCY: Int = systemProp(DEFAULT_CONCURRENCY_PROPERTY_NAME,
31+
public val DEFAULT_CONCURRENCY: Int = systemProp(
32+
DEFAULT_CONCURRENCY_PROPERTY_NAME,
3033
16, 1, Int.MAX_VALUE
3134
)
3235

@@ -39,7 +42,7 @@ public val DEFAULT_CONCURRENCY: Int = systemProp(DEFAULT_CONCURRENCY_PROPERTY_NA
3942
* Note that even though this operator looks very familiar, we discourage its usage in a regular application-specific flows.
4043
* Most likely, suspending operation in [map] operator will be sufficient and linear transformations are much easier to reason about.
4144
*/
42-
@FlowPreview
45+
@ExperimentalCoroutinesApi
4346
public fun <T, R> Flow<T>.flatMapConcat(transform: suspend (value: T) -> Flow<R>): Flow<R> =
4447
map(transform).flattenConcat()
4548

@@ -63,7 +66,7 @@ public fun <T, R> Flow<T>.flatMapConcat(transform: suspend (value: T) -> Flow<R>
6366
* @param concurrency controls the number of in-flight flows, at most [concurrency] flows are collected
6467
* at the same time. By default, it is equal to [DEFAULT_CONCURRENCY].
6568
*/
66-
@FlowPreview
69+
@ExperimentalCoroutinesApi
6770
public fun <T, R> Flow<T>.flatMapMerge(
6871
concurrency: Int = DEFAULT_CONCURRENCY,
6972
transform: suspend (value: T) -> Flow<R>
@@ -75,7 +78,7 @@ public fun <T, R> Flow<T>.flatMapMerge(
7578
*
7679
* Inner flows are collected by this operator *sequentially*.
7780
*/
78-
@FlowPreview
81+
@ExperimentalCoroutinesApi
7982
public fun <T> Flow<Flow<T>>.flattenConcat(): Flow<T> = flow {
8083
collect { value -> emitAll(value) }
8184
}
@@ -132,7 +135,7 @@ public fun <T> merge(vararg flows: Flow<T>): Flow<T> = flows.asIterable().merge(
132135
* @param concurrency controls the number of in-flight flows, at most [concurrency] flows are collected
133136
* at the same time. By default, it is equal to [DEFAULT_CONCURRENCY].
134137
*/
135-
@FlowPreview
138+
@ExperimentalCoroutinesApi
136139
public fun <T> Flow<Flow<T>>.flattenMerge(concurrency: Int = DEFAULT_CONCURRENCY): Flow<T> {
137140
require(concurrency > 0) { "Expected positive concurrency level, but had $concurrency" }
138141
return if (concurrency == 1) flattenConcat() else ChannelFlowMerge(this, concurrency)

reactive/kotlinx-coroutines-reactive/src/Migration.kt

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public fun <T : Any> Publisher<T>.asFlowDeprecated(): Flow<T> = asFlow()
3030
public fun <T : Any> Flow<T>.asPublisherDeprecated(): Publisher<T> = asPublisher()
3131

3232
/** @suppress */
33-
@FlowPreview
3433
@Deprecated(
3534
message = "batchSize parameter is deprecated, use .buffer() instead to control the backpressure",
3635
level = DeprecationLevel.HIDDEN,

0 commit comments

Comments
 (0)