2
2
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
3
*/
4
4
5
- @file:Suppress(" unused" )
5
+ @file:Suppress(" unused" , " INVISIBLE_REFERENCE " , " INVISIBLE_MEMBER " )
6
6
7
7
package kotlinx.coroutines.flow
8
8
9
9
import kotlinx.coroutines.*
10
10
import kotlin.coroutines.*
11
+ import kotlin.internal.InlineOnly
11
12
12
13
/* *
13
14
* Applying [cancellable][Flow.cancellable] to a [SharedFlow] has no effect.
@@ -79,4 +80,61 @@ public fun FlowCollector<*>.cancel(cause: CancellationException? = null): Unit =
79
80
replaceWith = ReplaceWith (" currentCoroutineContext()" )
80
81
)
81
82
public val FlowCollector <* >.coroutineContext: CoroutineContext
82
- get() = noImpl()
83
+ get() = noImpl()
84
+
85
+ @Deprecated(
86
+ message = " SharedFlow never completes, so this operator has no effect." ,
87
+ level = DeprecationLevel .WARNING ,
88
+ replaceWith = ReplaceWith (" this" )
89
+ )
90
+ @InlineOnly
91
+ public inline fun <T > SharedFlow<T>.catch (noinline action : suspend FlowCollector <T >.(cause: Throwable ) -> Unit ): Flow <T > =
92
+ (this as Flow <T >).catch (action)
93
+
94
+ @Deprecated(
95
+ message = " SharedFlow never completes, so this operator has no effect." ,
96
+ level = DeprecationLevel .WARNING ,
97
+ replaceWith = ReplaceWith (" this" )
98
+ )
99
+ @InlineOnly
100
+ public inline fun <T > SharedFlow<T>.retry (
101
+ retries : Long = Long .MAX_VALUE ,
102
+ noinline predicate : suspend (cause: Throwable ) -> Boolean = { true }
103
+ ): Flow <T > =
104
+ (this as Flow <T >).retry(retries, predicate)
105
+
106
+ @Deprecated(
107
+ message = " SharedFlow never completes, so this operator has no effect." ,
108
+ level = DeprecationLevel .WARNING ,
109
+ replaceWith = ReplaceWith (" this" )
110
+ )
111
+ @InlineOnly
112
+ public inline fun <T > SharedFlow<T>.retryWhen (noinline predicate : suspend FlowCollector <T >.(cause: Throwable , attempt: Long ) -> Boolean ): Flow <T > =
113
+ (this as Flow <T >).retryWhen(predicate)
114
+
115
+ @Deprecated(
116
+ message = " SharedFlow never completes, so this terminal operation never completes." ,
117
+ level = DeprecationLevel .WARNING ,
118
+ replaceWith = ReplaceWith (" awaitCancellation()" )
119
+ )
120
+ @InlineOnly
121
+ public suspend inline fun <T > SharedFlow<T>.toList (): List <T > =
122
+ (this as Flow <T >).toList()
123
+
124
+ @Deprecated(
125
+ message = " SharedFlow never completes, so this terminal operation never completes." ,
126
+ level = DeprecationLevel .WARNING ,
127
+ replaceWith = ReplaceWith (" awaitCancellation()" )
128
+ )
129
+ @InlineOnly
130
+ public suspend inline fun <T > SharedFlow<T>.toSet (): Set <T > =
131
+ (this as Flow <T >).toSet()
132
+
133
+ @Deprecated(
134
+ message = " SharedFlow never completes, so this terminal operation never completes." ,
135
+ level = DeprecationLevel .WARNING ,
136
+ replaceWith = ReplaceWith (" awaitCancellation()" )
137
+ )
138
+ @InlineOnly
139
+ public suspend inline fun <T > SharedFlow<T>.count (): Int =
140
+ (this as Flow <T >).count()
0 commit comments