Skip to content

Commit a231c5c

Browse files
ajaltthomasnield
authored andcommitted
Add blockingSubscribeBy (#119)
1 parent 872c00a commit a231c5c

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/main/kotlin/io/reactivex/rxkotlin/subscribers.kt

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
package io.reactivex.rxkotlin
22

3-
import io.reactivex.Completable
4-
import io.reactivex.Flowable
5-
import io.reactivex.Maybe
6-
import io.reactivex.Observable
7-
import io.reactivex.Single
3+
import io.reactivex.*
84
import io.reactivex.disposables.Disposable
95
import java.lang.RuntimeException
106

@@ -55,4 +51,22 @@ fun Completable.subscribeBy(
5551
onComplete: () -> Unit = onCompleteStub
5652
): Disposable = subscribe(onComplete, onError)
5753

54+
/**
55+
* Overloaded blockingSubscribe function that allow passing named parameters
56+
*/
57+
fun <T : Any> Observable<T>.blockingSubscribeBy(
58+
onNext: (T) -> Unit = onNextStub,
59+
onError: (Throwable) -> Unit = onErrorStub,
60+
onComplete: () -> Unit = onCompleteStub
61+
) = blockingSubscribe(onNext, onError, onComplete)
62+
63+
/**
64+
* Overloaded blockingSubscribe function that allow passing named parameters
65+
*/
66+
fun <T : Any> Flowable<T>.blockingSubscribeBy(
67+
onNext: (T) -> Unit = onNextStub,
68+
onError: (Throwable) -> Unit = onErrorStub,
69+
onComplete: () -> Unit = onCompleteStub
70+
) = blockingSubscribe(onNext, onError, onComplete)
71+
5872
class OnErrorNotImplementedException(e: Throwable) : RuntimeException(e)

0 commit comments

Comments
 (0)