Skip to content

Commit 3ed7a7d

Browse files
committed
Fix docs in "Guide to reactive streams with coroutines" and reknit
Fixes #1274
1 parent e8e9f00 commit 3ed7a7d

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

coroutines-guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The main coroutines guide has moved to the [docs folder](docs/coroutines-guide.m
5151
* <a name='supervision-scope'></a>[Supervision scope](docs/exception-handling.md#supervision-scope)
5252
* <a name='exceptions-in-supervised-coroutines'></a>[Exceptions in supervised coroutines](docs/exception-handling.md#exceptions-in-supervised-coroutines)
5353
<!--- TOC_REF docs/channels.md -->
54-
* <a name='channels-experimental'></a>[Channels (experimental)](docs/channels.md#channels-experimental)
54+
* <a name='channels'></a>[Channels](docs/channels.md#channels)
5555
* <a name='channel-basics'></a>[Channel basics](docs/channels.md#channel-basics)
5656
* <a name='closing-and-iteration-over-channels'></a>[Closing and iteration over channels](docs/channels.md#closing-and-iteration-over-channels)
5757
* <a name='building-channel-producers'></a>[Building channel producers](docs/channels.md#building-channel-producers)

reactive/coroutines-guide-reactive.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,7 @@ fun <T, U> Publisher<T>.takeUntil(context: CoroutineContext, other: Publisher<U>
687687
```
688688

689689
This code is using [whileSelect] as a nicer shortcut to `while(select{...}) {}` loop and Kotlin's
690-
[use](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io/use.html)
691-
expression to close the channels on exit, which unsubscribes from the corresponding publishers.
690+
[consume] expressions to close the channels on exit, which unsubscribes from the corresponding publishers.
692691

693692
The following hand-written combination of
694693
[range](https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html#range(int,%20int)) with
@@ -751,11 +750,8 @@ fun <T> Publisher<Publisher<T>>.merge(context: CoroutineContext) = GlobalScope.p
751750
}
752751
```
753752

754-
Notice the use of
755-
[coroutineContext](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/coroutine-context.html)
756-
in the invocation of [launch] coroutine builder. It is used to refer
757-
to the context of the enclosing `publish` coroutine. This way, all the coroutines that are
758-
being launched here are [children](../docs/coroutines-guide.md#children-of-a-coroutine) of the `publish`
753+
Notice that all the coroutines that are
754+
being launched here are the children of the `publish`
759755
coroutine and will get cancelled when the `publish` coroutine is cancelled or is otherwise completed.
760756
Moreover, since the parent coroutine waits until all the children are complete, this implementation fully
761757
merges all the received streams.
@@ -1052,7 +1048,6 @@ coroutines for complex pipelines with fan-in and fan-out between multiple worker
10521048
[runBlocking]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/run-blocking.html
10531049
[Dispatchers.Unconfined]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-unconfined.html
10541050
[yield]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/yield.html
1055-
[launch]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/launch.html
10561051
[Dispatchers.Default]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-default.html
10571052
[Job.join]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/join.html
10581053
<!--- INDEX kotlinx.coroutines.channels -->

reactive/kotlinx-coroutines-rx2/test/guide/example-reactive-basic-08.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ fun main() = runBlocking<Unit> {
2121
subject.onNext("three")
2222
subject.onNext("four")
2323
yield() // yield the main thread to the launched coroutine <--- HERE
24-
subject.onComplete() // now complete subject's sequence to cancel consumer, too
24+
subject.onComplete() // now complete the subject's sequence to cancel the consumer, too
2525
}

reactive/kotlinx-coroutines-rx2/test/guide/example-reactive-basic-09.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ fun main() = runBlocking<Unit> {
2020
broadcast.offer("three")
2121
broadcast.offer("four")
2222
yield() // yield the main thread to the launched coroutine
23-
broadcast.close() // now close broadcast channel to cancel consumer, too
23+
broadcast.close() // now close the broadcast channel to cancel the consumer, too
2424
}

0 commit comments

Comments
 (0)