blob: 5035efe23ca23cff1655df335a2198c7a840a3c8 [file] [log] [blame]
Roman Elizarov3258e1f2019-08-22 20:08:48 +03001/*
2 * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
5// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
6package kotlinx.coroutines.guide.flow30
7
8import kotlinx.coroutines.*
9import kotlinx.coroutines.flow.*
10
11fun foo(): Flow<Int> = flow {
12 for (i in 1..3) {
13 println("Emitting $i")
14 emit(i)
15 }
16}
17
18fun main() = runBlocking<Unit> {
19 foo()
20 .onEach { value ->
21 check(value <= 1) { "Collected $value" }
22 println(value)
23 }
24 .catch { e -> println("Caught $e") }
25 .collect()
26}