• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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-reactive.md by Knit tool. Do not edit.
6 package kotlinx.coroutines.rx2.guide.context02
7 
8 import io.reactivex.*
9 import kotlinx.coroutines.*
10 import kotlinx.coroutines.reactive.*
11 import kotlin.coroutines.CoroutineContext
12 
<lambda>null13 fun rangeWithInterval(context: CoroutineContext, time: Long, start: Int, count: Int) = publish<Int>(context) {
14     for (x in start until start + count) {
15         delay(time) // wait before sending each number
16         send(x)
17     }
18 }
19 
mainnull20 fun main() {
21     Flowable.fromPublisher(rangeWithInterval(Dispatchers.Default, 100, 1, 3))
22         .subscribe { println("$it on thread ${Thread.currentThread().name}") }
23     Thread.sleep(1000)
24 }
25