File tree Expand file tree Collapse file tree 2 files changed +26
-20
lines changed
kotlinx-coroutines-core/common/src/flow Expand file tree Collapse file tree 2 files changed +26
-20
lines changed Original file line number Diff line number Diff line change 88
99package kotlinx.coroutines.flow
1010
11+ import kotlinx.coroutines.*
12+ import kotlinx.coroutines.flow.internal.*
13+ import kotlinx.coroutines.flow.internal.unsafeFlow
1114import kotlin.coroutines.*
1215import kotlin.jvm.*
1316
@@ -361,3 +364,26 @@ public fun <T> Flow<T>.concatWith(value: T): Flow<T> = noImpl()
361364)
362365public fun <T > Flow<T>.concatWith (other : Flow <T >): Flow <T > = noImpl()
363366
367+ /* *
368+ * Delays the emission of values from this flow for the given [timeMillis].
369+ * Use `onStart { delay(timeMillis) }`.
370+ * @suppress
371+ */
372+ @Deprecated(
373+ level = DeprecationLevel .WARNING , // since 1.3.0, error in 1.4.0
374+ message = " Use 'onStart { delay(timeMillis) }'" ,
375+ replaceWith = ReplaceWith (" onStart { delay(timeMillis) }" )
376+ )
377+ public fun <T > Flow<T>.delayFlow (timeMillis : Long ): Flow <T > = onStart { delay(timeMillis) }
378+
379+ /* *
380+ * Delays each element emitted by the given flow for the given [timeMillis].
381+ * Use `onEach { delay(timeMillis) }`.
382+ * @suppress
383+ */
384+ @Deprecated(
385+ level = DeprecationLevel .WARNING , // since 1.3.0, error in 1.4.0
386+ message = " Use 'onEach { delay(timeMillis) }'" ,
387+ replaceWith = ReplaceWith (" onEach { delay(timeMillis) }" )
388+ )
389+ public fun <T > Flow<T>.delayEach (timeMillis : Long ): Flow <T > = onEach { delay(timeMillis) }
Original file line number Diff line number Diff line change @@ -14,26 +14,6 @@ import kotlinx.coroutines.selects.*
1414import kotlin.jvm.*
1515import kotlinx.coroutines.flow.internal.unsafeFlow as flow
1616
17- /* *
18- * Delays the emission of values from this flow for the given [timeMillis].
19- */
20- @ExperimentalCoroutinesApi
21- public fun <T > Flow<T>.delayFlow (timeMillis : Long ): Flow <T > = flow {
22- delay(timeMillis)
23- collect(this @flow)
24- }
25-
26- /* *
27- * Delays each element emitted by the given flow for the given [timeMillis].
28- */
29- @ExperimentalCoroutinesApi
30- public fun <T > Flow<T>.delayEach (timeMillis : Long ): Flow <T > = flow {
31- collect { value ->
32- delay(timeMillis)
33- emit(value)
34- }
35- }
36-
3717/* *
3818 * Returns a flow that mirrors the original flow, but filters out values
3919 * that are followed by the newer values within the given [timeout][timeoutMillis].
You can’t perform that action at this time.
0 commit comments