Skip to content

Instantly share code, notes, and snippets.

@smhdk
Created December 4, 2018 14:12
Show Gist options
  • Save smhdk/9d4760dd3365d4039174d7339ba45cb4 to your computer and use it in GitHub Desktop.
Save smhdk/9d4760dd3365d4039174d7339ba45cb4 to your computer and use it in GitHub Desktop.
RxJava Merge Operator Example with Kotlin
val alphabets1 = Observable.intervalRange(0, 3, 1, 1, TimeUnit.SECONDS).map { id -> "A" + id }
val alphabets2 = Observable.intervalRange(0, 3, 2, 1, TimeUnit.SECONDS).map { id -> "B" + id }
Observable.merge(alphabets1, alphabets2)
.subscribe(object : Observer<String> {
override fun onComplete() {
println("onComplete")
}
override fun onSubscribe(d: Disposable) {
println("onSubscribe")
}
override fun onNext(t: String) {
println("onNext: $t")
}
override fun onError(e: Throwable) {
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment