blob: b5da8ee86ac210818db30af5b377528d3684d1db [file] [log] [blame]
Vsevolod Tolstopyatovd57bfa22019-04-04 14:25:13 +03001/*
2 * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4@file:Suppress("unused", "DeprecatedCallableAddReplaceWith", "UNUSED_PARAMETER")
5package kotlinx.coroutines.flow
6
7import kotlin.coroutines.*
8
9/**
10 * These deprecations are added to improve user experience when they will start to
11 * search for their favourite operators and/or patterns that are missing or renamed in Flow.
12 */
13
14/** @suppress **/
15@Deprecated(message = "Use flowWith or flowOn instead", level = DeprecationLevel.ERROR)
16public fun <T> Flow<T>.subscribeOn(context: CoroutineContext): Flow<T> = error("Should not be called")
17
18/** @suppress **/
19@Deprecated(message = "Use flowWith or flowOn instead", level = DeprecationLevel.ERROR)
20public fun <T> Flow<T>.observeOn(context: CoroutineContext): Flow<T> = error("Should not be called")
21
22/** @suppress **/
23@Deprecated(message = "Use flowWith or flowOn instead", level = DeprecationLevel.ERROR)
24public fun <T> Flow<T>.publishOn(context: CoroutineContext): Flow<T> = error("Should not be called")
25
26/** @suppress **/
27@Deprecated(message = "Use BroadcastChannel.asFlow()", level = DeprecationLevel.ERROR)
28public fun BehaviourSubject(): Any = error("Should not be called")
29
30/** @suppress **/
31@Deprecated(
32 message = "ReplaySubject is not supported. The closest analogue is buffered broadcast channel",
33 level = DeprecationLevel.ERROR)
34public fun ReplaySubject(): Any = error("Should not be called")
35
36/** @suppress **/
37@Deprecated(message = "PublishSubject is not supported", level = DeprecationLevel.ERROR)
38public fun PublishSubject(): Any = error("Should not be called")
39
40/** @suppress **/
41@Deprecated(
42 level = DeprecationLevel.ERROR,
43 message = "Flow analogue is named onErrorCollect",
44 replaceWith = ReplaceWith("onErrorCollect(fallback)")
45)
46public fun <T> Flow<T>.onErrorResume(fallback: Flow<T>): Flow<T> = error("Should not be called")
47
48
49/** @suppress **/
50@Suppress("UNUSED_PARAMETER", "UNUSED", "DeprecatedCallableAddReplaceWith")
51@Deprecated(message = "withContext in flow body is deprecated, use flowOn instead", level = DeprecationLevel.ERROR)
52public fun <T, R> FlowCollector<T>.withContext(context: CoroutineContext, block: suspend () -> R): Unit = error("Should not be called")
53
54
55/** @suppress **/
56@Deprecated(message = "Use launch + collect instead", level = DeprecationLevel.ERROR)
57public fun <T> Flow<T>.subscribe(): Unit = error("Should not be called")
58
59/** @suppress **/
60@Deprecated(message = "Use launch + collect instead", level = DeprecationLevel.ERROR)
61public fun <T> Flow<T>.subscribe(onEach: (T) -> Unit): Unit = error("Should not be called")
62
63/** @suppress **/
64@Deprecated(message = "Use launch + collect instead", level = DeprecationLevel.ERROR)
65public fun <T> Flow<T>.subscribe(onEach: (T) -> Unit, onError: (Throwable) -> Unit): Unit = error("Should not be called")
66
Vsevolod Tolstopyatov87884882019-04-09 18:36:22 +030067
68/**
69 * Note that this replacement is sequential (`concat`) by default.
70 * For concurrent flatMap [flatMapMerge] can be used instead.
71 * @suppress
72 */
Vsevolod Tolstopyatovd57bfa22019-04-04 14:25:13 +030073@Deprecated(
74 level = DeprecationLevel.ERROR,
Vsevolod Tolstopyatov87884882019-04-09 18:36:22 +030075 message = "Flow analogue is named flatMapConcat",
76 replaceWith = ReplaceWith("flatMapConcat(mapper)")
Vsevolod Tolstopyatovd57bfa22019-04-04 14:25:13 +030077)
Vsevolod Tolstopyatov87884882019-04-09 18:36:22 +030078public fun <T, R> Flow<T>.flatMap(mapper: suspend (T) -> Flow<R>): Flow<R> = error("Should not be called")
Vsevolod Tolstopyatovd57bfa22019-04-04 14:25:13 +030079
80/** @suppress **/
81@Deprecated(
82 level = DeprecationLevel.ERROR,
Vsevolod Tolstopyatov87884882019-04-09 18:36:22 +030083 message = "Flow analogue is named flatMapConcat",
84 replaceWith = ReplaceWith("flatMapConcat(mapper)")
Vsevolod Tolstopyatovd57bfa22019-04-04 14:25:13 +030085)
86public fun <T, R> Flow<T>.concatMap(mapper: (T) -> Flow<R>): Flow<R> = error("Should not be called")
Vsevolod Tolstopyatov87884882019-04-09 18:36:22 +030087
88
89/**
90 * Note that this replacement is sequential (`concat`) by default.
91 * For concurrent flatMap [flattenMerge] can be used instead.
92 * @suppress
93 */
94@Deprecated(
95 level = DeprecationLevel.ERROR,
96 message = "Flow analogue is named flattenConcat",
97 replaceWith = ReplaceWith("flattenConcat()")
98)
99public fun <T> Flow<Flow<T>>.merge(): Flow<T> = error("Should not be called")
100
101/** @suppress **/
102@Deprecated(
103 level = DeprecationLevel.ERROR,
104 message = "Flow analogue is named flattenConcat",
105 replaceWith = ReplaceWith("flattenConcat()")
106)
107public fun <T> Flow<Flow<T>>.flatten(): Flow<T> = error("Should not be called")