• 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.basic07
7 
8 import io.reactivex.subjects.BehaviorSubject
9 import kotlinx.coroutines.*
10 import kotlinx.coroutines.rx2.collect
11 
<lambda>null12 fun main() = runBlocking<Unit> {
13     val subject = BehaviorSubject.create<String>()
14     subject.onNext("one")
15     subject.onNext("two")
16     // now launch a coroutine to print everything
17     GlobalScope.launch(Dispatchers.Unconfined) { // launch coroutine in unconfined context
18         subject.collect { println(it) }
19     }
20     subject.onNext("three")
21     subject.onNext("four")
22 }
23