22 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33 */
44
5- @file:Suppress(" unused" )
5+ @file:Suppress(" unused" , " INVISIBLE_REFERENCE " , " INVISIBLE_MEMBER " )
66
77package kotlinx.coroutines.flow
88
99import kotlinx.coroutines.*
1010import kotlin.coroutines.*
11+ import kotlin.internal.InlineOnly
1112
1213/* *
1314 * Applying [cancellable][Flow.cancellable] to a [SharedFlow] has no effect.
@@ -79,4 +80,61 @@ public fun FlowCollector<*>.cancel(cause: CancellationException? = null): Unit =
7980 replaceWith = ReplaceWith (" currentCoroutineContext()" )
8081)
8182public 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+ @Suppress(" DeprecatedCallableAddReplaceWith" )
116+ @Deprecated(
117+ message = " SharedFlow never completes, so this terminal operation never completes." ,
118+ level = DeprecationLevel .WARNING
119+ )
120+ @InlineOnly
121+ public suspend inline fun <T > SharedFlow<T>.toList (): List <T > =
122+ (this as Flow <T >).toList()
123+
124+ @Suppress(" DeprecatedCallableAddReplaceWith" )
125+ @Deprecated(
126+ message = " SharedFlow never completes, so this terminal operation never completes." ,
127+ level = DeprecationLevel .WARNING
128+ )
129+ @InlineOnly
130+ public suspend inline fun <T > SharedFlow<T>.toSet (): Set <T > =
131+ (this as Flow <T >).toSet()
132+
133+ @Suppress(" DeprecatedCallableAddReplaceWith" )
134+ @Deprecated(
135+ message = " SharedFlow never completes, so this terminal operation never completes." ,
136+ level = DeprecationLevel .WARNING
137+ )
138+ @InlineOnly
139+ public suspend inline fun <T > SharedFlow<T>.count (): Int =
140+ (this as Flow <T >).count()
0 commit comments