Skip to content

Commit 4a53433

Browse files
committed
kotlinCoroutinesVersion = "1.6.0-RC2"
1 parent a2f498a commit 4a53433

14 files changed

+26
-20
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
- Update
44
- `Kotlin` to `1.6.0`.
5-
- `KotlinX Coroutines` to `1.6.0-RC`.
5+
- `KotlinX Coroutines` to `1.6.0-RC2`.
66

77
- Do not propagate cancellation to the upstream in Flow `flatMapFirst` operators
88
(Related to https://github.com/Kotlin/kotlinx.coroutines/pull/2964).
99

1010
- Remove unnecessary `@ExperimentalCoroutinesApi`.
1111

12-
- Rename `NULL_Value` to `NullValue`.
12+
- Rename `NULL_Value` to `NULL_VALUE`.
1313

1414
- Add `Flow.mapIndexed`.
1515

build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ repositories {
2323
gradlePluginPortal()
2424
}
2525

26-
val kotlinCoroutinesVersion = "1.6.0-RC"
27-
val ktlintVersion = "0.43.0"
26+
val kotlinCoroutinesVersion = "1.6.0-RC2"
27+
val ktlintVersion = "0.43.2"
2828

2929
kotlin {
3030
explicitApi()

src/commonMain/kotlin/com/hoc081098/flowext/NullValue.kt renamed to src/commonMain/kotlin/com/hoc081098/flowext/NULL_VALUE.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ package com.hoc081098.flowext
55
* This allows for writing faster generic code instead of using `Option`.
66
* This is only used as an optimisation technique in low-level code.
77
*/
8-
public object NullValue {
8+
@Suppress("ClassName")
9+
public object NULL_VALUE {
910
@Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE")
1011
public inline fun <T> unbox(v: Any?): T = if (this === v) null as T else v as T
1112
}

src/commonMain/kotlin/com/hoc081098/flowext/bufferCount.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.hoc081098.flowext
22

3+
import kotlinx.coroutines.InternalCoroutinesApi
34
import kotlinx.coroutines.flow.Flow
4-
import kotlinx.coroutines.flow.collect
55
import kotlinx.coroutines.flow.flow
66

77
/**
@@ -13,6 +13,7 @@ import kotlinx.coroutines.flow.flow
1313
* For example if [startBufferEvery] is 2, then a new buffer will be started on every other value from the source.
1414
* A new buffer is started at the beginning of the source by default.
1515
*/
16+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
1617
public fun <T> Flow<T>.bufferCount(
1718
bufferSize: Int,
1819
startBufferEvery: Int? = null,
@@ -26,6 +27,7 @@ public fun <T> Flow<T>.bufferCount(
2627
}
2728
}
2829

30+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
2931
private fun <T> Flow<T>.bufferSkip(bufferSize: Int, skip: Int): Flow<List<T>> {
3032
return flow {
3133
val buffers = ArrayDeque<MutableList<T>>()
@@ -70,6 +72,7 @@ private fun <T> Flow<T>.bufferSkip(bufferSize: Int, skip: Int): Flow<List<T>> {
7072
}
7173
}
7274

75+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
7376
private fun <T> Flow<T>.bufferExact(bufferSize: Int): Flow<List<T>> {
7477
return flow {
7578
var buffer: MutableList<T> = mutableListOf()

src/commonMain/kotlin/com/hoc081098/flowext/flatMapFirst.kt

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.hoc081098.flowext
22

33
import com.hoc081098.flowext.internal.AtomicBoolean
44
import kotlinx.coroutines.CoroutineStart
5+
import kotlinx.coroutines.InternalCoroutinesApi
56
import kotlinx.coroutines.flow.Flow
67
import kotlinx.coroutines.flow.buffer
78
import kotlinx.coroutines.flow.channelFlow
@@ -24,12 +25,14 @@ import kotlinx.coroutines.launch
2425
*
2526
* @param transform A transform function to apply to value that was observed while no Flow is executing in parallel.
2627
*/
28+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
2729
public fun <T, R> Flow<T>.flatMapFirst(transform: suspend (value: T) -> Flow<R>): Flow<R> =
2830
map(transform).flattenFirst()
2931

3032
/**
3133
* Converts a higher-order [Flow] into a first-order [Flow] by dropping inner [Flow] while the previous inner [Flow] has not yet completed.
3234
*/
35+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
3336
public fun <T> Flow<Flow<T>>.flattenFirst(): Flow<T> = channelFlow {
3437
val busy = AtomicBoolean(false)
3538

@@ -50,11 +53,13 @@ public fun <T> Flow<Flow<T>>.flattenFirst(): Flow<T> = channelFlow {
5053
/**
5154
* This function is an alias to [flatMapFirst] operator.
5255
*/
56+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
5357
public fun <T, R> Flow<T>.exhaustMap(transform: suspend (value: T) -> Flow<R>): Flow<R> =
5458
flatMapFirst(transform)
5559

5660
/**
5761
* This function is an alias to [flattenFirst] operator.
5862
*/
63+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
5964
@Suppress("NOTHING_TO_INLINE")
6065
public inline fun <T> Flow<Flow<T>>.exhaustAll(): Flow<T> = flattenFirst()

src/commonMain/kotlin/com/hoc081098/flowext/interval.kt

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import kotlinx.coroutines.delay
44
import kotlinx.coroutines.flow.Flow
55
import kotlinx.coroutines.flow.flow
66
import kotlin.time.Duration
7-
import kotlin.time.ExperimentalTime
87

98
/**
109
* Returns a [Flow] that emits a 0L after the [initialDelay] and ever-increasing numbers
@@ -13,7 +12,6 @@ import kotlin.time.ExperimentalTime
1312
* @param initialDelay must be greater than or equal to [Duration.ZERO]
1413
* @param period must be greater than or equal to [Duration.ZERO]
1514
*/
16-
@ExperimentalTime
1715
public fun interval(
1816
initialDelay: Duration,
1917
period: Duration,

src/commonMain/kotlin/com/hoc081098/flowext/mapIndexed.kt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.hoc081098.flowext
22

3+
import kotlinx.coroutines.InternalCoroutinesApi
34
import kotlinx.coroutines.flow.Flow
45
import kotlinx.coroutines.flow.collect
56
import kotlinx.coroutines.flow.flow
@@ -8,6 +9,7 @@ import kotlinx.coroutines.flow.flow
89
* Returns a flow containing the results of applying the given [transform] function
910
* to each value and its index in the original flow.
1011
*/
12+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
1113
public fun <T, R> Flow<T>.mapIndexed(transform: suspend (index: Int, value: T) -> R): Flow<R> =
1214
flow {
1315
var index = 0

src/commonMain/kotlin/com/hoc081098/flowext/materialize_dematerialize.kt

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.hoc081098.flowext
22

33
import com.hoc081098.flowext.internal.ClosedException
44
import com.hoc081098.flowext.internal.checkOwnership
5+
import kotlinx.coroutines.InternalCoroutinesApi
56
import kotlinx.coroutines.flow.Flow
67
import kotlinx.coroutines.flow.catch
78
import kotlinx.coroutines.flow.collect
@@ -19,6 +20,7 @@ public fun <T> Flow<T>.materialize(): Flow<Event<T>> = map<T, Event<T>> { Event.
1920
/**
2021
* Converts a [Flow] of [Event] objects into the emissions that they represent.
2122
*/
23+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
2224
public fun <T> Flow<Event<T>>.dematerialize(): Flow<T> = flow {
2325
try {
2426
collect {

src/commonMain/kotlin/com/hoc081098/flowext/retryWhenWithDelayStrategy.kt

-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import kotlinx.coroutines.flow.FlowCollector
66
import kotlinx.coroutines.flow.retryWhen
77
import kotlin.math.pow
88
import kotlin.time.Duration
9-
import kotlin.time.ExperimentalTime
109

11-
@ExperimentalTime
1210
public fun <T> Flow<T>.retryWhenWithDelayStrategy(
1311
strategy: DelayStrategy,
1412
predicate: suspend FlowCollector<T>.(cause: Throwable, attempt: Long) -> Boolean
@@ -42,7 +40,6 @@ public fun interface DelayStrategy {
4240
}
4341
}
4442

45-
@ExperimentalTime
4643
public fun <T> Flow<T>.retryWhenWithExponentialBackoff(
4744
initialDelay: Duration,
4845
factor: Double,
@@ -57,7 +54,6 @@ public fun <T> Flow<T>.retryWhenWithExponentialBackoff(
5754
predicate = predicate,
5855
)
5956

60-
@ExperimentalTime
6157
public fun <T> Flow<T>.retryWithExponentialBackoff(
6258
initialDelay: Duration,
6359
factor: Double,

src/commonMain/kotlin/com/hoc081098/flowext/takeUntil.kt

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.hoc081098.flowext
33
import com.hoc081098.flowext.internal.ClosedException
44
import com.hoc081098.flowext.internal.checkOwnership
55
import kotlinx.coroutines.CoroutineStart
6+
import kotlinx.coroutines.InternalCoroutinesApi
67
import kotlinx.coroutines.coroutineScope
78
import kotlinx.coroutines.flow.Flow
89
import kotlinx.coroutines.flow.collect
@@ -16,6 +17,7 @@ import kotlinx.coroutines.launch
1617
* @param notifier The [Flow] whose first emitted value or complete event
1718
* will cause the output [Flow] of [takeUntil] to stop emitting values from the source [Flow].
1819
*/
20+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
1921
public fun <T, R> Flow<T>.takeUntil(notifier: Flow<R>): Flow<T> = flow {
2022
try {
2123
coroutineScope {

src/commonMain/kotlin/com/hoc081098/flowext/timer.kt

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import kotlinx.coroutines.delay
44
import kotlinx.coroutines.flow.Flow
55
import kotlinx.coroutines.flow.flow
66
import kotlin.time.Duration
7-
import kotlin.time.ExperimentalTime
87

98
/**
109
* Creates a [Flow] that will wait for a specified time, before emitting the [value].
@@ -17,7 +16,6 @@ public fun <T> timer(value: T, timeMillis: Long): Flow<T> = flow {
1716
/**
1817
* Creates a [Flow] that will wait for a given [duration], before emitting the [value].
1918
*/
20-
@ExperimentalTime
2119
public fun <T> timer(value: T, duration: Duration): Flow<T> = flow {
2220
delay(duration)
2321
emit(value)

src/commonMain/kotlin/com/hoc081098/flowext/withLatestFrom.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.hoc081098.flowext
22

33
import kotlinx.coroutines.CoroutineStart
4+
import kotlinx.coroutines.InternalCoroutinesApi
45
import kotlinx.coroutines.channels.Channel
56
import kotlinx.coroutines.channels.onSuccess
67
import kotlinx.coroutines.coroutineScope
@@ -16,6 +17,7 @@ import kotlinx.coroutines.launch
1617
* @param other Second [Flow]
1718
* @param transform A transform function to apply to each value from self combined with the latest value from the second [Flow], if any.
1819
*/
20+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
1921
public fun <A, B, R> Flow<A>.withLatestFrom(
2022
other: Flow<B>,
2123
transform: suspend (A, B) -> R
@@ -25,7 +27,7 @@ public fun <A, B, R> Flow<A>.withLatestFrom(
2527
val otherValues = Channel<Any>(Channel.CONFLATED)
2628
launch(start = CoroutineStart.UNDISPATCHED) {
2729
other.collect {
28-
return@collect otherValues.send(it ?: NullValue)
30+
return@collect otherValues.send(it ?: NULL_VALUE)
2931
}
3032
}
3133

@@ -38,14 +40,15 @@ public fun <A, B, R> Flow<A>.withLatestFrom(
3840
emit(
3941
transform(
4042
value,
41-
NullValue.unbox(lastValue ?: return@collect)
43+
NULL_VALUE.unbox(lastValue ?: return@collect)
4244
),
4345
)
4446
}
4547
}
4648
}
4749
}
4850

51+
@InternalCoroutinesApi // TODO: Remove InternalCoroutinesApi (https://github.com/Kotlin/kotlinx.coroutines/issues/3078)
4952
@Suppress("NOTHING_TO_INLINE")
5053
public inline fun <A, B> Flow<A>.withLatestFrom(other: Flow<B>): Flow<Pair<A, B>> =
5154
withLatestFrom(other) { a, b -> a to b }

src/commonTest/kotlin/com/hoc081098/flowext/RetryWhenWithDelayStrategyTest.kt

-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import kotlin.test.assertEquals
1111
import kotlin.test.assertIs
1212
import kotlin.time.Duration
1313
import kotlin.time.Duration.Companion.milliseconds
14-
import kotlin.time.ExperimentalTime
1514

16-
@ExperimentalTime
1715
@ExperimentalCoroutinesApi
1816
@InternalCoroutinesApi
1917
class RetryWhenWithDelayStrategyTest {

src/commonTest/kotlin/com/hoc081098/flowext/TakeUntilTest.kt

-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ import kotlin.test.assertEquals
1313
import kotlin.test.assertIs
1414
import kotlin.time.Duration.Companion.milliseconds
1515
import kotlin.time.Duration.Companion.seconds
16-
import kotlin.time.ExperimentalTime
1716

1817
@InternalCoroutinesApi
19-
@ExperimentalTime
2018
@ExperimentalCoroutinesApi
2119
class TakeUntilTest {
2220
@Test

0 commit comments

Comments
 (0)