@@ -6,11 +6,11 @@ import io.reactivex.rxjava3.annotations.CheckReturnValue
6
6
import io.reactivex.rxjava3.annotations.SchedulerSupport
7
7
import io.reactivex.rxjava3.core.*
8
8
import io.reactivex.rxjava3.disposables.Disposable
9
+ import io.reactivex.rxjava3.disposables.DisposableContainer
9
10
import io.reactivex.rxjava3.functions.Action
10
11
import io.reactivex.rxjava3.functions.Consumer
11
12
import io.reactivex.rxjava3.internal.functions.Functions
12
13
13
-
14
14
private val onNextStub: (Any ) -> Unit = {}
15
15
private val onErrorStub: (Throwable ) -> Unit = {}
16
16
private val onCompleteStub: () -> Unit = {}
@@ -33,9 +33,9 @@ private fun (() -> Unit).asOnCompleteAction(): Action {
33
33
@CheckReturnValue
34
34
@SchedulerSupport(SchedulerSupport .NONE )
35
35
fun <T : Any > Observable<T>.subscribeBy (
36
- onError : (Throwable ) -> Unit = onErrorStub,
37
- onComplete : () -> Unit = onCompleteStub,
38
- onNext : (T ) -> Unit = onNextStub
36
+ onError : (Throwable ) -> Unit = onErrorStub,
37
+ onComplete : () -> Unit = onCompleteStub,
38
+ onNext : (T ) -> Unit = onNextStub
39
39
): Disposable = subscribe(onNext.asConsumer(), onError.asOnErrorConsumer(), onComplete.asOnCompleteAction())
40
40
41
41
/* *
@@ -45,9 +45,9 @@ fun <T : Any> Observable<T>.subscribeBy(
45
45
@BackpressureSupport(BackpressureKind .UNBOUNDED_IN )
46
46
@SchedulerSupport(SchedulerSupport .NONE )
47
47
fun <T : Any > Flowable<T>.subscribeBy (
48
- onError : (Throwable ) -> Unit = onErrorStub,
49
- onComplete : () -> Unit = onCompleteStub,
50
- onNext : (T ) -> Unit = onNextStub
48
+ onError : (Throwable ) -> Unit = onErrorStub,
49
+ onComplete : () -> Unit = onCompleteStub,
50
+ onNext : (T ) -> Unit = onNextStub
51
51
): Disposable = subscribe(onNext.asConsumer(), onError.asOnErrorConsumer(), onComplete.asOnCompleteAction())
52
52
53
53
/* *
@@ -56,8 +56,8 @@ fun <T : Any> Flowable<T>.subscribeBy(
56
56
@CheckReturnValue
57
57
@SchedulerSupport(SchedulerSupport .NONE )
58
58
fun <T : Any > Single<T>.subscribeBy (
59
- onError : (Throwable ) -> Unit = onErrorStub,
60
- onSuccess : (T ) -> Unit = onNextStub
59
+ onError : (Throwable ) -> Unit = onErrorStub,
60
+ onSuccess : (T ) -> Unit = onNextStub
61
61
): Disposable = subscribe(onSuccess.asConsumer(), onError.asOnErrorConsumer())
62
62
63
63
/* *
@@ -66,9 +66,9 @@ fun <T : Any> Single<T>.subscribeBy(
66
66
@CheckReturnValue
67
67
@SchedulerSupport(SchedulerSupport .NONE )
68
68
fun <T : Any > Maybe<T>.subscribeBy (
69
- onError : (Throwable ) -> Unit = onErrorStub,
70
- onComplete : () -> Unit = onCompleteStub,
71
- onSuccess : (T ) -> Unit = onNextStub
69
+ onError : (Throwable ) -> Unit = onErrorStub,
70
+ onComplete : () -> Unit = onCompleteStub,
71
+ onSuccess : (T ) -> Unit = onNextStub
72
72
): Disposable = subscribe(onSuccess.asConsumer(), onError.asOnErrorConsumer(), onComplete.asOnCompleteAction())
73
73
74
74
/* *
@@ -77,8 +77,8 @@ fun <T : Any> Maybe<T>.subscribeBy(
77
77
@CheckReturnValue
78
78
@SchedulerSupport(SchedulerSupport .NONE )
79
79
fun Completable.subscribeBy (
80
- onError : (Throwable ) -> Unit = onErrorStub,
81
- onComplete : () -> Unit = onCompleteStub
80
+ onError : (Throwable ) -> Unit = onErrorStub,
81
+ onComplete : () -> Unit = onCompleteStub
82
82
): Disposable = when {
83
83
// There are optimized versions of the completable Consumers, so we need to use the subscribe overloads
84
84
// here.
@@ -87,14 +87,69 @@ fun Completable.subscribeBy(
87
87
else -> subscribe(onComplete.asOnCompleteAction(), Consumer (onError))
88
88
}
89
89
90
+ /* *
91
+ * Overloaded subscribe function that allows passing named parameters
92
+ */
93
+ @SchedulerSupport(SchedulerSupport .NONE )
94
+ fun <T : Any > Observable<T>.subscribeBy (
95
+ container : DisposableContainer ,
96
+ onError : (Throwable ) -> Unit = onErrorStub,
97
+ onComplete : () -> Unit = onCompleteStub,
98
+ onNext : (T ) -> Unit = onNextStub
99
+ ): Disposable = subscribe(onNext.asConsumer(), onError.asOnErrorConsumer(), onComplete.asOnCompleteAction(), container)
100
+
101
+ /* *
102
+ * Overloaded subscribe function that allows passing named parameters
103
+ */
104
+ @BackpressureSupport(BackpressureKind .UNBOUNDED_IN )
105
+ @SchedulerSupport(SchedulerSupport .NONE )
106
+ fun <T : Any > Flowable<T>.subscribeBy (
107
+ container : DisposableContainer ,
108
+ onError : (Throwable ) -> Unit = onErrorStub,
109
+ onComplete : () -> Unit = onCompleteStub,
110
+ onNext : (T ) -> Unit = onNextStub
111
+ ): Disposable = subscribe(onNext.asConsumer(), onError.asOnErrorConsumer(), onComplete.asOnCompleteAction(), container)
112
+
113
+ /* *
114
+ * Overloaded subscribe function that allows passing named parameters
115
+ */
116
+ @SchedulerSupport(SchedulerSupport .NONE )
117
+ fun <T : Any > Single<T>.subscribeBy (
118
+ container : DisposableContainer ,
119
+ onError : (Throwable ) -> Unit = onErrorStub,
120
+ onSuccess : (T ) -> Unit = onNextStub
121
+ ): Disposable = subscribe(onSuccess.asConsumer(), onError.asOnErrorConsumer(), container)
122
+
123
+ /* *
124
+ * Overloaded subscribe function that allows passing named parameters
125
+ */
126
+ @SchedulerSupport(SchedulerSupport .NONE )
127
+ fun <T : Any > Maybe<T>.subscribeBy (
128
+ container : DisposableContainer ,
129
+ onError : (Throwable ) -> Unit = onErrorStub,
130
+ onComplete : () -> Unit = onCompleteStub,
131
+ onSuccess : (T ) -> Unit = onNextStub
132
+ ): Disposable =
133
+ subscribe(onSuccess.asConsumer(), onError.asOnErrorConsumer(), onComplete.asOnCompleteAction(), container)
134
+
135
+ /* *
136
+ * Overloaded subscribe function that allows passing named parameters
137
+ */
138
+ @SchedulerSupport(SchedulerSupport .NONE )
139
+ fun Completable.subscribeBy (
140
+ container : DisposableContainer ,
141
+ onError : (Throwable ) -> Unit = onErrorStub,
142
+ onComplete : () -> Unit = onCompleteStub
143
+ ): Disposable = subscribe(onComplete.asOnCompleteAction(), onError.asOnErrorConsumer(), container)
144
+
90
145
/* *
91
146
* Overloaded blockingSubscribe function that allows passing named parameters
92
147
*/
93
148
@SchedulerSupport(SchedulerSupport .NONE )
94
149
fun <T : Any > Observable<T>.blockingSubscribeBy (
95
- onError : (Throwable ) -> Unit = onErrorStub,
96
- onComplete : () -> Unit = onCompleteStub,
97
- onNext : (T ) -> Unit = onNextStub
150
+ onError : (Throwable ) -> Unit = onErrorStub,
151
+ onComplete : () -> Unit = onCompleteStub,
152
+ onNext : (T ) -> Unit = onNextStub
98
153
): Unit = blockingSubscribe(onNext.asConsumer(), onError.asOnErrorConsumer(), onComplete.asOnCompleteAction())
99
154
100
155
/* *
@@ -103,35 +158,35 @@ fun <T : Any> Observable<T>.blockingSubscribeBy(
103
158
@BackpressureSupport(BackpressureKind .UNBOUNDED_IN )
104
159
@SchedulerSupport(SchedulerSupport .NONE )
105
160
fun <T : Any > Flowable<T>.blockingSubscribeBy (
106
- onError : (Throwable ) -> Unit = onErrorStub,
107
- onComplete : () -> Unit = onCompleteStub,
108
- onNext : (T ) -> Unit = onNextStub
161
+ onError : (Throwable ) -> Unit = onErrorStub,
162
+ onComplete : () -> Unit = onCompleteStub,
163
+ onNext : (T ) -> Unit = onNextStub
109
164
): Unit = blockingSubscribe(onNext.asConsumer(), onError.asOnErrorConsumer(), onComplete.asOnCompleteAction())
110
165
111
166
/* *
112
167
* Overloaded blockingSubscribe function that allows passing named parameters
113
168
*/
114
169
@SchedulerSupport(SchedulerSupport .NONE )
115
170
fun <T : Any > Maybe<T>.blockingSubscribeBy (
116
- onError : (Throwable ) -> Unit = onErrorStub,
117
- onComplete : () -> Unit = onCompleteStub,
118
- onSuccess : (T ) -> Unit = onNextStub
119
- ) : Unit = blockingSubscribe(onSuccess.asConsumer(), onError.asOnErrorConsumer(), onComplete.asOnCompleteAction())
171
+ onError : (Throwable ) -> Unit = onErrorStub,
172
+ onComplete : () -> Unit = onCompleteStub,
173
+ onSuccess : (T ) -> Unit = onNextStub
174
+ ): Unit = blockingSubscribe(onSuccess.asConsumer(), onError.asOnErrorConsumer(), onComplete.asOnCompleteAction())
120
175
121
176
/* *
122
177
* Overloaded blockingSubscribe function that allows passing named parameters
123
178
*/
124
179
@SchedulerSupport(SchedulerSupport .NONE )
125
180
fun <T : Any > Single<T>.blockingSubscribeBy (
126
- onError : (Throwable ) -> Unit = onErrorStub,
127
- onSuccess : (T ) -> Unit = onNextStub
128
- ) : Unit = blockingSubscribe(onSuccess.asConsumer(), onError.asOnErrorConsumer())
181
+ onError : (Throwable ) -> Unit = onErrorStub,
182
+ onSuccess : (T ) -> Unit = onNextStub
183
+ ): Unit = blockingSubscribe(onSuccess.asConsumer(), onError.asOnErrorConsumer())
129
184
130
185
/* *
131
186
* Overloaded blockingSubscribe function that allows passing named parameters
132
187
*/
133
188
@SchedulerSupport(SchedulerSupport .NONE )
134
189
fun Completable.blockingSubscribeBy (
135
- onError : (Throwable ) -> Unit = onErrorStub,
136
- onComplete : () -> Unit = onCompleteStub
190
+ onError : (Throwable ) -> Unit = onErrorStub,
191
+ onComplete : () -> Unit = onCompleteStub
137
192
): Unit = blockingSubscribe(onComplete.asOnCompleteAction(), onError.asOnErrorConsumer())
0 commit comments