Skip to content

Commit

Permalink
Extract example output from comment to text block (#4018)
Browse files Browse the repository at this point in the history
  • Loading branch information
zUniQueX committed Apr 13, 2024
1 parent 918b1cc commit aa72711
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/topics/flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,14 +677,16 @@ fun main() = runBlocking<Unit> {

Notice how `flow { ... }` works in the background thread, while collection happens in the main thread:

<!--- TEST FLEXIBLE_THREAD
```text
[DefaultDispatcher-worker-1 @coroutine#2] Emitting 1
[main @coroutine#1] Collected 1
[DefaultDispatcher-worker-1 @coroutine#2] Emitting 2
[main @coroutine#1] Collected 2
[DefaultDispatcher-worker-1 @coroutine#2] Emitting 3
[main @coroutine#1] Collected 3
-->
```

<!--- TEST FLEXIBLE_THREAD -->

Another thing to observe here is that the [flowOn] operator has changed the default sequential nature of the flow.
Now collection happens in one coroutine ("coroutine#1") and emission happens in another coroutine
Expand Down

0 comments on commit aa72711

Please sign in to comment.