• 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.exampleFlow21
7 
8 import kotlinx.coroutines.*
9 import kotlinx.coroutines.flow.*
10 
11 fun main() = runBlocking<Unit> {
12     val nums = (1..3).asFlow().onEach { delay(300) } // numbers 1..3 every 300 ms
13     val strs = flowOf("one", "two", "three").onEach { delay(400) } // strings every 400 ms
14     val startTime = currentTimeMillis() // remember the start time
15     nums.zip(strs) { a, b -> "$a -> $b" } // compose a single string with "zip"
16         .collect { value -> // collect and print
17             println("$value at ${currentTimeMillis() - startTime} ms from start")
18         }
19 }
20