Reactive scopeless (#1341)
Make all reactive builders top-level functions instead of extensions on CoroutineScope and prohibit jobs in their context
Downsides of having lifecycle-managed scoped builders:
* The lifecycle of semantically cold entity is managed externally by the hot-one.
* Independent failures in independent triggered computations affect each other
* Two cancellation sources should be managed, coroutine-related Job parent and disposable/subscription
diff --git a/reactive/kotlinx-coroutines-rx2/test/ConvertTest.kt b/reactive/kotlinx-coroutines-rx2/test/ConvertTest.kt
index 475ee57..ba14b89 100644
--- a/reactive/kotlinx-coroutines-rx2/test/ConvertTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/ConvertTest.kt
@@ -16,7 +16,7 @@
val job = launch {
expect(3)
}
- val completable = job.asCompletable(coroutineContext)
+ val completable = job.asCompletable(coroutineContext.minusKey(Job))
completable.subscribe {
expect(4)
}
@@ -32,7 +32,7 @@
expect(3)
throw RuntimeException("OK")
}
- val completable = job.asCompletable(coroutineContext)
+ val completable = job.asCompletable(coroutineContext.minusKey(Job))
completable.subscribe {
expect(4)
}
@@ -140,7 +140,7 @@
throw TestException("K")
}
val observable = c.asObservable(Dispatchers.Unconfined)
- val single = GlobalScope.rxSingle(Dispatchers.Unconfined) {
+ val single = rxSingle(Dispatchers.Unconfined) {
var result = ""
try {
observable.consumeEach { result += it }