Skip to content

Instantly share code, notes, and snippets.

@longv
Last active February 1, 2021 22:35
Show Gist options
  • Save longv/a28fff57e55bab84f1e9211566315ba7 to your computer and use it in GitHub Desktop.
Save longv/a28fff57e55bab84f1e9211566315ba7 to your computer and use it in GitHub Desktop.
fun debugSubscribeOn(): Disposable =
Observable.just(1)
.doOnNext {
println(Thread.currentThread().name) // RxCachedThreadScheduler-1
}
.subscribeOn(Schedulers.io())
.flatMap {
println(Thread.currentThread().name) // RxCachedThreadScheduler-1
Observable.just(it)
.doOnNext {
println(Thread.currentThread().name) // RxCachedThreadScheduler-1
}
}
.subscribeOn(Schedulers.newThread())
.doOnNext {
println(Thread.currentThread().name) // RxCachedThreadScheduler-1
}
.subscribe()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment