Skip to content

Commit 64571aa

Browse files
committed
Merge remote-tracking branch 'origin/master' into develop
2 parents d718970 + ccdc563 commit 64571aa

24 files changed

+112
-112
lines changed

docs/flow.md

Lines changed: 64 additions & 64 deletions
Large diffs are not rendered by default.

kotlinx-coroutines-core/jvm/test/guide/example-flow-01.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// This file was automatically generated from flow.md by Knit tool. Do not edit.
66
package kotlinx.coroutines.guide.exampleFlow01
77

8-
fun foo(): List<Int> = listOf(1, 2, 3)
8+
fun simple(): List<Int> = listOf(1, 2, 3)
99

1010
fun main() {
11-
foo().forEach { value -> println(value) }
11+
simple().forEach { value -> println(value) }
1212
}

kotlinx-coroutines-core/jvm/test/guide/example-flow-02.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
// This file was automatically generated from flow.md by Knit tool. Do not edit.
66
package kotlinx.coroutines.guide.exampleFlow02
77

8-
fun foo(): Sequence<Int> = sequence { // sequence builder
8+
fun simple(): Sequence<Int> = sequence { // sequence builder
99
for (i in 1..3) {
1010
Thread.sleep(100) // pretend we are computing it
1111
yield(i) // yield next value
1212
}
1313
}
1414

1515
fun main() {
16-
foo().forEach { value -> println(value) }
16+
simple().forEach { value -> println(value) }
1717
}

kotlinx-coroutines-core/jvm/test/guide/example-flow-03.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ package kotlinx.coroutines.guide.exampleFlow03
77

88
import kotlinx.coroutines.*
99

10-
suspend fun foo(): List<Int> {
10+
suspend fun simple(): List<Int> {
1111
delay(1000) // pretend we are doing something asynchronous here
1212
return listOf(1, 2, 3)
1313
}
1414

1515
fun main() = runBlocking<Unit> {
16-
foo().forEach { value -> println(value) }
16+
simple().forEach { value -> println(value) }
1717
}

kotlinx-coroutines-core/jvm/test/guide/example-flow-04.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package kotlinx.coroutines.guide.exampleFlow04
88
import kotlinx.coroutines.*
99
import kotlinx.coroutines.flow.*
1010

11-
fun foo(): Flow<Int> = flow { // flow builder
11+
fun simple(): Flow<Int> = flow { // flow builder
1212
for (i in 1..3) {
1313
delay(100) // pretend we are doing something useful here
1414
emit(i) // emit next value
@@ -24,5 +24,5 @@ fun main() = runBlocking<Unit> {
2424
}
2525
}
2626
// Collect the flow
27-
foo().collect { value -> println(value) }
27+
simple().collect { value -> println(value) }
2828
}

kotlinx-coroutines-core/jvm/test/guide/example-flow-05.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package kotlinx.coroutines.guide.exampleFlow05
88
import kotlinx.coroutines.*
99
import kotlinx.coroutines.flow.*
1010

11-
fun foo(): Flow<Int> = flow {
11+
fun simple(): Flow<Int> = flow {
1212
println("Flow started")
1313
for (i in 1..3) {
1414
delay(100)
@@ -17,8 +17,8 @@ fun foo(): Flow<Int> = flow {
1717
}
1818

1919
fun main() = runBlocking<Unit> {
20-
println("Calling foo...")
21-
val flow = foo()
20+
println("Calling simple function...")
21+
val flow = simple()
2222
println("Calling collect...")
2323
flow.collect { value -> println(value) }
2424
println("Calling collect again...")

kotlinx-coroutines-core/jvm/test/guide/example-flow-06.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package kotlinx.coroutines.guide.exampleFlow06
88
import kotlinx.coroutines.*
99
import kotlinx.coroutines.flow.*
1010

11-
fun foo(): Flow<Int> = flow {
11+
fun simple(): Flow<Int> = flow {
1212
for (i in 1..3) {
1313
delay(100)
1414
println("Emitting $i")
@@ -18,7 +18,7 @@ fun foo(): Flow<Int> = flow {
1818

1919
fun main() = runBlocking<Unit> {
2020
withTimeoutOrNull(250) { // Timeout after 250ms
21-
foo().collect { value -> println(value) }
21+
simple().collect { value -> println(value) }
2222
}
2323
println("Done")
2424
}

kotlinx-coroutines-core/jvm/test/guide/example-flow-13.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import kotlinx.coroutines.flow.*
1010

1111
fun log(msg: String) = println("[${Thread.currentThread().name}] $msg")
1212

13-
fun foo(): Flow<Int> = flow {
14-
log("Started foo flow")
13+
fun simple(): Flow<Int> = flow {
14+
log("Started simple flow")
1515
for (i in 1..3) {
1616
emit(i)
1717
}
1818
}
1919

2020
fun main() = runBlocking<Unit> {
21-
foo().collect { value -> log("Collected $value") }
21+
simple().collect { value -> log("Collected $value") }
2222
}

kotlinx-coroutines-core/jvm/test/guide/example-flow-14.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package kotlinx.coroutines.guide.exampleFlow14
88
import kotlinx.coroutines.*
99
import kotlinx.coroutines.flow.*
1010

11-
fun foo(): Flow<Int> = flow {
11+
fun simple(): Flow<Int> = flow {
1212
// The WRONG way to change context for CPU-consuming code in flow builder
1313
kotlinx.coroutines.withContext(Dispatchers.Default) {
1414
for (i in 1..3) {
@@ -19,5 +19,5 @@ fun foo(): Flow<Int> = flow {
1919
}
2020

2121
fun main() = runBlocking<Unit> {
22-
foo().collect { value -> println(value) }
22+
simple().collect { value -> println(value) }
2323
}

kotlinx-coroutines-core/jvm/test/guide/example-flow-15.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.*
1010

1111
fun log(msg: String) = println("[${Thread.currentThread().name}] $msg")
1212

13-
fun foo(): Flow<Int> = flow {
13+
fun simple(): Flow<Int> = flow {
1414
for (i in 1..3) {
1515
Thread.sleep(100) // pretend we are computing it in CPU-consuming way
1616
log("Emitting $i")
@@ -19,7 +19,7 @@ fun foo(): Flow<Int> = flow {
1919
}.flowOn(Dispatchers.Default) // RIGHT way to change context for CPU-consuming code in flow builder
2020

2121
fun main() = runBlocking<Unit> {
22-
foo().collect { value ->
22+
simple().collect { value ->
2323
log("Collected $value")
2424
}
2525
}

0 commit comments

Comments
 (0)