Skip to content

Instantly share code, notes, and snippets.

@SODA1127
Created January 7, 2020 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SODA1127/add115dc883ba1d587a1921dc0129fcf to your computer and use it in GitHub Desktop.
Save SODA1127/add115dc883ba1d587a1921dc0129fcf to your computer and use it in GitHub Desktop.
fun main(args: Array<String>) {
val connectableObservable = Observable.interval(100,TimeUnit.MILLISECONDS)
.publish()//1
connectableObservable.
subscribe { println("Subscription 1: $it") }//2
connectableObservable
.subscribe { println("Subscription 2 $it")}//3
connectableObservable.connect()//4
runBlocking { delay(500) }//5
connectableObservable.
subscribe { println("Subscription 3: $it") }//6
runBlocking { delay(500) }//7
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment