Vsevolod Tolstopyatov | d57bfa2 | 2019-04-04 14:25:13 +0300 | [diff] [blame] | 1 | /* |
| 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") |
| 5 | package kotlinx.coroutines.flow |
| 6 | |
| 7 | import 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) |
| 16 | public 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) |
| 20 | public 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) |
| 24 | public 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) |
| 28 | public 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) |
| 34 | public fun ReplaySubject(): Any = error("Should not be called") |
| 35 | |
| 36 | /** @suppress **/ |
| 37 | @Deprecated(message = "PublishSubject is not supported", level = DeprecationLevel.ERROR) |
| 38 | public 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 | ) |
| 46 | public 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) |
| 52 | public 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) |
| 57 | public fun <T> Flow<T>.subscribe(): Unit = error("Should not be called") |
| 58 | |
| 59 | /** @suppress **/ |
| 60 | @Deprecated(message = "Use launch + collect instead", level = DeprecationLevel.ERROR) |
| 61 | public 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) |
| 65 | public fun <T> Flow<T>.subscribe(onEach: (T) -> Unit, onError: (Throwable) -> Unit): Unit = error("Should not be called") |
| 66 | |
Vsevolod Tolstopyatov | 8788488 | 2019-04-09 18:36:22 +0300 | [diff] [blame^] | 67 | |
| 68 | /** |
| 69 | * Note that this replacement is sequential (`concat`) by default. |
| 70 | * For concurrent flatMap [flatMapMerge] can be used instead. |
| 71 | * @suppress |
| 72 | */ |
Vsevolod Tolstopyatov | d57bfa2 | 2019-04-04 14:25:13 +0300 | [diff] [blame] | 73 | @Deprecated( |
| 74 | level = DeprecationLevel.ERROR, |
Vsevolod Tolstopyatov | 8788488 | 2019-04-09 18:36:22 +0300 | [diff] [blame^] | 75 | message = "Flow analogue is named flatMapConcat", |
| 76 | replaceWith = ReplaceWith("flatMapConcat(mapper)") |
Vsevolod Tolstopyatov | d57bfa2 | 2019-04-04 14:25:13 +0300 | [diff] [blame] | 77 | ) |
Vsevolod Tolstopyatov | 8788488 | 2019-04-09 18:36:22 +0300 | [diff] [blame^] | 78 | public fun <T, R> Flow<T>.flatMap(mapper: suspend (T) -> Flow<R>): Flow<R> = error("Should not be called") |
Vsevolod Tolstopyatov | d57bfa2 | 2019-04-04 14:25:13 +0300 | [diff] [blame] | 79 | |
| 80 | /** @suppress **/ |
| 81 | @Deprecated( |
| 82 | level = DeprecationLevel.ERROR, |
Vsevolod Tolstopyatov | 8788488 | 2019-04-09 18:36:22 +0300 | [diff] [blame^] | 83 | message = "Flow analogue is named flatMapConcat", |
| 84 | replaceWith = ReplaceWith("flatMapConcat(mapper)") |
Vsevolod Tolstopyatov | d57bfa2 | 2019-04-04 14:25:13 +0300 | [diff] [blame] | 85 | ) |
| 86 | public fun <T, R> Flow<T>.concatMap(mapper: (T) -> Flow<R>): Flow<R> = error("Should not be called") |
Vsevolod Tolstopyatov | 8788488 | 2019-04-09 18:36:22 +0300 | [diff] [blame^] | 87 | |
| 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 | ) |
| 99 | public 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 | ) |
| 107 | public fun <T> Flow<Flow<T>>.flatten(): Flow<T> = error("Should not be called") |