File tree 3 files changed +9
-5
lines changed
kotlinx-coroutines-reactive/src/main/kotlin/kotlinx/coroutines/experimental/reactive
kotlinx-coroutines-reactor/src/main/kotlin/kotlinx/coroutines/experimental/reactor
3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 16
16
17
17
package kotlinx.coroutines.experimental.reactive
18
18
19
+ import kotlinx.coroutines.experimental.DefaultDispatcher
19
20
import kotlinx.coroutines.experimental.channels.ReceiveChannel
20
21
import org.reactivestreams.Publisher
21
22
import kotlin.coroutines.experimental.CoroutineContext
@@ -28,7 +29,7 @@ import kotlin.coroutines.experimental.CoroutineContext
28
29
*
29
30
* @param context -- the coroutine context from which the resulting observable is going to be signalled
30
31
*/
31
- public fun <T > ReceiveChannel<T>.asPublisher (context : CoroutineContext ): Publisher <T > = publish(context) {
32
+ public fun <T > ReceiveChannel<T>.asPublisher (context : CoroutineContext = DefaultDispatcher ): Publisher <T > = publish(context) {
32
33
for (t in this @asPublisher)
33
34
send(t)
34
35
}
Original file line number Diff line number Diff line change 1
1
package kotlinx.coroutines.experimental.reactor
2
2
3
+ import kotlinx.coroutines.experimental.DefaultDispatcher
3
4
import kotlinx.coroutines.experimental.Deferred
4
5
import kotlinx.coroutines.experimental.Job
5
6
import kotlinx.coroutines.experimental.channels.ReceiveChannel
@@ -16,7 +17,7 @@ import kotlin.coroutines.experimental.CoroutineContext
16
17
*
17
18
* @param context -- the coroutine context from which the resulting mono is going to be signalled
18
19
*/
19
- public fun Job.asMono (context : CoroutineContext ): Mono <Unit > = mono(context) { this @asMono.join() }
20
+ public fun Job.asMono (context : CoroutineContext = DefaultDispatcher ): Mono <Unit > = mono(context) { this @asMono.join() }
20
21
21
22
/* *
22
23
* Converts this deferred value to the hot reactive mono that signals
@@ -27,7 +28,7 @@ public fun Job.asMono(context: CoroutineContext): Mono<Unit> = mono(context) { t
27
28
*
28
29
* @param context -- the coroutine context from which the resulting mono is going to be signalled
29
30
*/
30
- public fun <T > Deferred<T?>.asMono (context : CoroutineContext ): Mono <T > = mono(context) { this @asMono.await() }
31
+ public fun <T > Deferred<T?>.asMono (context : CoroutineContext = DefaultDispatcher ): Mono <T > = mono(context) { this @asMono.await() }
31
32
32
33
/* *
33
34
* Converts a stream of elements received from the channel to the hot reactive flux.
@@ -37,7 +38,7 @@ public fun <T> Deferred<T?>.asMono(context: CoroutineContext): Mono<T> = mono(co
37
38
*
38
39
* @param context -- the coroutine context from which the resulting flux is going to be signalled
39
40
*/
40
- public fun <T > ReceiveChannel<T>.asFlux (context : CoroutineContext ): Flux <T > = flux(context) {
41
+ public fun <T > ReceiveChannel<T>.asFlux (context : CoroutineContext = DefaultDispatcher ): Flux <T > = flux(context) {
41
42
for (t in this @asFlux)
42
43
send(t)
43
44
}
Original file line number Diff line number Diff line change 1
1
package kotlinx.coroutines.experimental.reactor
2
2
3
+ import kotlinx.coroutines.experimental.DefaultDispatcher
3
4
import kotlinx.coroutines.experimental.channels.ProducerScope
4
5
import kotlinx.coroutines.experimental.reactive.publish
5
6
import reactor.core.publisher.Flux
@@ -19,7 +20,8 @@ import kotlin.coroutines.experimental.CoroutineContext
19
20
* | Normal completion or `close` without cause | `onComplete`
20
21
* | Failure with exception or `close` with cause | `onError`
21
22
*/
23
+ @JvmOverloads // for binary compatibility with older code compiled before context had a default
22
24
fun <T > flux (
23
- context : CoroutineContext ,
25
+ context : CoroutineContext = DefaultDispatcher ,
24
26
block : suspend ProducerScope <T >.() -> Unit
25
27
): Flux <T > = Flux .from(publish(context, block))
You can’t perform that action at this time.
0 commit comments