@@ -5,18 +5,14 @@ import reactor.util.context.Context
5
5
import kotlin.coroutines.*
6
6
7
7
/* *
8
- * Marks coroutine context element that contains Reactor's [Context] elements in [context] for seamless integration
9
- * between [CoroutineContext] and Reactor's [Context].
8
+ * Wraps Reactor's [Context] into [CoroutineContext] element for seamless integration Reactor and kotlinx.coroutines.
10
9
*
11
10
* [Context.asCoroutineContext] is defined to add Reactor's [Context] elements as part of [CoroutineContext].
12
11
*
13
- * Reactor builders: [mono], [flux] can extract the reactor context from their coroutine context and
14
- * pass it on. Modifications of reactor context can be retrieved by `coroutineContext[ReactorContext]`.
15
- *
16
- * Example usage:
12
+ * Reactor builders [mono] and [flux] use this context element to enhance the resulting `subscriberContext`.
17
13
*
14
+ * ### Usages
18
15
* Passing reactor context from coroutine builder to reactor entity:
19
- *
20
16
* ```
21
17
* launch(Context.of("key", "value").asCoroutineContext()) {
22
18
* mono {
@@ -25,8 +21,7 @@ import kotlin.coroutines.*
25
21
* }
26
22
* ```
27
23
*
28
- * Accessing modified reactor context enriched from downstream via coroutine context:
29
- *
24
+ * Accessing modified reactor context enriched from the downstream:
30
25
* ```
31
26
* launch {
32
27
* mono {
@@ -41,10 +36,9 @@ public class ReactorContext(val context: Context) : AbstractCoroutineContextElem
41
36
companion object Key : CoroutineContext.Key<ReactorContext>
42
37
}
43
38
44
-
45
39
/* *
46
40
* Wraps the given [Context] into [ReactorContext], so it can be added to coroutine's context
47
- * and later retrieved via `coroutineContext[ReactorContext]`.
41
+ * and later used via `coroutineContext[ReactorContext]`.
48
42
*/
49
43
@ExperimentalCoroutinesApi
50
- public fun Context.asCoroutineContext (): CoroutineContext = ReactorContext (this )
44
+ public fun Context.asCoroutineContext (): ReactorContext = ReactorContext (this )
0 commit comments