blob: d3a391a1de0ee0f5304402561143e40bd97c898d [file] [log] [blame]
Roman Elizarov8a4a8e12017-03-09 19:52:58 +03001/*
Roman Elizarov1f74a2d2018-06-29 19:19:45 +03002 * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
Roman Elizarov8a4a8e12017-03-09 19:52:58 +03003 */
4
5// This file was automatically generated from coroutines-guide-reactive.md by Knit tool. Do not edit.
Roman Elizarova9687a32018-06-29 17:28:38 +03006package kotlinx.coroutines.experimental.rx2.guide.context01
Roman Elizarov8a4a8e12017-03-09 19:52:58 +03007
Roman Elizarov95981f32017-03-17 18:12:04 +03008import io.reactivex.*
Roman Elizarov8a4a8e12017-03-09 19:52:58 +03009import io.reactivex.functions.BiFunction
10import io.reactivex.schedulers.Schedulers
11import java.util.concurrent.TimeUnit
12
13fun rangeWithIntervalRx(scheduler: Scheduler, time: Long, start: Int, count: Int): Flowable<Int> =
14 Flowable.zip(
15 Flowable.range(start, count),
16 Flowable.interval(time, TimeUnit.MILLISECONDS, scheduler),
17 BiFunction { x, _ -> x })
18
19fun main(args: Array<String>) {
Roman Elizarov86349be2017-03-17 16:47:37 +030020 rangeWithIntervalRx(Schedulers.computation(), 100, 1, 3)
21 .subscribe { println("$it on thread ${Thread.currentThread().name}") }
Roman Elizarov8a4a8e12017-03-09 19:52:58 +030022 Thread.sleep(1000)
23}