Skip to content

Commit 54afb19

Browse files
Dmitry-Borodinqwwdfsad
authored andcommitted
Aligned to RxJava2 contract - Observable and Single returns non nullable type <T>.
Fixes #347
1 parent e18b015 commit 54afb19

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

reactive/kotlinx-coroutines-rx2/src/RxConvert.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public fun <T> Deferred<T?>.asMaybe(context: CoroutineContext): Maybe<T> = Globa
5656
* @param context -- the coroutine context from which the resulting single is going to be signalled
5757
*/
5858
@ExperimentalCoroutinesApi
59-
public fun <T> Deferred<T>.asSingle(context: CoroutineContext): Single<T> = GlobalScope.rxSingle(context) {
59+
public fun <T : Any> Deferred<T>.asSingle(context: CoroutineContext): Single<T> = GlobalScope.rxSingle(context) {
6060
this@asSingle.await()
6161
}
6262

@@ -72,7 +72,7 @@ public fun <T> Deferred<T>.asSingle(context: CoroutineContext): Single<T> = Glob
7272
* @param context -- the coroutine context from which the resulting observable is going to be signalled
7373
*/
7474
@ObsoleteCoroutinesApi
75-
public fun <T> ReceiveChannel<T>.asObservable(context: CoroutineContext): Observable<T> = GlobalScope.rxObservable(context) {
75+
public fun <T : Any> ReceiveChannel<T>.asObservable(context: CoroutineContext): Observable<T> = GlobalScope.rxObservable(context) {
7676
for (t in this@asObservable)
7777
send(t)
7878
}

reactive/kotlinx-coroutines-rx2/src/RxObservable.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ import kotlin.coroutines.experimental.*
3434
*
3535
* **Note: This is an experimental api.** Behaviour of publishers that work as children in a parent scope with respect
3636
* to cancellation and error handling may change in the future.
37-
*
37+
*
3838
* @param context context of the coroutine.
3939
* @param block the coroutine code.
4040
*/
4141
@ExperimentalCoroutinesApi
42-
public fun <T> CoroutineScope.rxObservable(
42+
public fun <T : Any> CoroutineScope.rxObservable(
4343
context: CoroutineContext = EmptyCoroutineContext,
4444
block: suspend ProducerScope<T>.() -> Unit
4545
): Observable<T> = Observable.create { subscriber ->
@@ -58,7 +58,7 @@ public fun <T> CoroutineScope.rxObservable(
5858
replaceWith = ReplaceWith("GlobalScope.rxObservable(context, block)",
5959
imports = ["kotlinx.coroutines.experimental.GlobalScope", "kotlinx.coroutines.experimental.rx2.rxObservable"])
6060
)
61-
public fun <T> rxObservable(
61+
public fun <T : Any> rxObservable(
6262
context: CoroutineContext = Dispatchers.Default,
6363
parent: Job? = null,
6464
block: suspend ProducerScope<T>.() -> Unit

reactive/kotlinx-coroutines-rx2/src/RxSingle.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import kotlin.coroutines.experimental.*
2727
* @param context context of the coroutine.
2828
* @param block the coroutine code.
2929
*/
30-
public fun <T> CoroutineScope.rxSingle(
30+
public fun <T : Any> CoroutineScope.rxSingle(
3131
context: CoroutineContext = EmptyCoroutineContext,
3232
block: suspend CoroutineScope.() -> T
3333
): Single<T> = Single.create { subscriber ->
@@ -46,7 +46,7 @@ public fun <T> CoroutineScope.rxSingle(
4646
replaceWith = ReplaceWith("GlobalScope.rxSingle(context, block)",
4747
imports = ["kotlinx.coroutines.experimental.GlobalScope", "kotlinx.coroutines.experimental.rx2.rxSingle"])
4848
)
49-
public fun <T> rxSingle(
49+
public fun <T : Any> rxSingle(
5050
context: CoroutineContext = Dispatchers.Default,
5151
parent: Job? = null,
5252
block: suspend CoroutineScope.() -> T

0 commit comments

Comments
 (0)