• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
<lambda>null2  * Copyright 2016-2020 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 flow.md by Knit tool. Do not edit.
6 package kotlinx.coroutines.guide.exampleFlow05
7 
8 import kotlinx.coroutines.*
9 import kotlinx.coroutines.flow.*
10 
11 fun simple(): Flow<Int> = flow {
12     println("Flow started")
13     for (i in 1..3) {
14         delay(100)
15         emit(i)
16     }
17 }
18 
<lambda>null19 fun main() = runBlocking<Unit> {
20     println("Calling simple function...")
21     val flow = simple()
22     println("Calling collect...")
23     flow.collect { value -> println(value) }
24     println("Calling collect again...")
25     flow.collect { value -> println(value) }
26 }
27