This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val observable1 = Observable.interval(400, TimeUnit.MILLISECONDS) | |
val observable2 = Observable.interval(250, TimeUnit.MILLISECONDS) | |
Observable.combineLatest( | |
observable1, | |
observable2, | |
object : BiFunction<Long, Long, String> { | |
override fun apply(t1: Long, t2: Long): String { | |
return "observable1 value: $t1 , observable2 value: $t2" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val firstObservable = Observable.interval(600, TimeUnit.MILLISECONDS) | |
val secondObservable = Observable.interval(100, TimeUnit.MILLISECONDS) | |
Observable | |
.switchOnNext(firstObservable.map { it -> secondObservable }) | |
.subscribe(object : Observer<Long> { | |
override fun onComplete() { | |
println("onComplete") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable | |
.switchOnNext( | |
Observable.interval(100, TimeUnit.MILLISECONDS).map { i -> | |
Observable.interval(30, TimeUnit.MILLISECONDS).map { i2 -> i } | |
}) | |
.take(6) | |
.subscribe(object : Observer<Long> { | |
override fun onComplete() { | |
println("onComplete") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val alphabets1 = Observable.intervalRange(0, 1, 1, 1, TimeUnit.SECONDS).map { id -> "A" + id } | |
val alphabets2 = Observable.intervalRange(0, 2, 2, 1, TimeUnit.SECONDS).map { id -> "B" + id } | |
Observable.zip(alphabets1, alphabets2, | |
BiFunction<String, String, String> { t1, t2 -> "$t1 $t2" }) | |
.subscribe(object : Observer<String> { | |
override fun onComplete() { | |
println("onComplete") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.concat(alphabets1, alphabets2) | |
.subscribe(object : Observer<String> { | |
override fun onComplete() { | |
println("onComplete") | |
} | |
override fun onSubscribe(d: Disposable) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable.just(1, 2, 3, 4, 5, 6, 7, 8) | |
.takeLast(4) | |
.subscribe(object : Observer<Int> { | |
override fun onComplete() { | |
println("onComplete") | |
} | |
override fun onSubscribe(d: Disposable) { | |
println("onSubscribe") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable.just(1, 2, 3, 4, 5, 6, 7, 8) | |
.take(4) | |
.subscribe(object : Observer<Int> { | |
override fun onComplete() { | |
println("onComplete") | |
} | |
override fun onSubscribe(d: Disposable) { | |
println("onSubscribe") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable.just(1, 2, 3, 4, 5, 6, 7, 8) | |
.skipLast(3) | |
.subscribe(object : Observer<Int> { | |
override fun onComplete() { | |
println("onComplete") | |
} | |
override fun onSubscribe(d: Disposable) { | |
println("onSubscribe") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable.just(1, 2, 3, 4, 5, 6, 7, 8) | |
.skip(3) | |
.subscribe(object : Observer<Int> { | |
override fun onComplete() { | |
println("onComplete") | |
} | |
override fun onSubscribe(d: Disposable) { | |
println("onSubscribe") | |
} |
NewerOlder