Skip to content

Instantly share code, notes, and snippets.

Semih Dik smhdk

Block or report user

Report or block smhdk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@smhdk
smhdk / rxjava-combine-latest-operator-example.kt
Created Dec 7, 2018
RxJava CombineLatest Operator Example with Kotlin
View rxjava-combine-latest-operator-example.kt
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"
}
@smhdk
smhdk / rxjava-switch-on-next-operator-example.kt
Created Dec 5, 2018
RxJava SwitchOnNext Operator Example with Kotlin
View rxjava-switch-on-next-operator-example.kt
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")
}
@smhdk
smhdk / rxjava-switchOnNext-operator-example.kt
Last active Dec 4, 2018
RxJava SwitchOnNext Operator with Kotlin
View rxjava-switchOnNext-operator-example.kt
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")
}
@smhdk
smhdk / rxjava-zip-operator-example.kt
Created Dec 4, 2018
RxJava Zip Operator Example with Kotlin
View rxjava-zip-operator-example.kt
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")
}
@smhdk
smhdk / rxjava-concat-operator-example.kt
Created Dec 4, 2018
RxJava Concat Operator Example with Kotlin
View rxjava-concat-operator-example.kt
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) {
@smhdk
smhdk / rxjava-merge-operator-example.kt
Created Dec 4, 2018
RxJava Merge Operator Example with Kotlin
View rxjava-merge-operator-example.kt
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) {
@smhdk
smhdk / rxjava-takelast-operator-example.kt
Created Dec 4, 2018
RxJava TakeLast Operator Example with Kotlin
View rxjava-takelast-operator-example.kt
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")
}
@smhdk
smhdk / rxjava-take-operator-example.kt
Created Dec 4, 2018
RxJava Take Operator Example with Kotlin
View rxjava-take-operator-example.kt
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")
}
@smhdk
smhdk / rxjava-skip-last-operator-example.kt
Created Dec 4, 2018
RxJava SkipLast Operator Example with Kotlin
View rxjava-skip-last-operator-example.kt
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")
}
@smhdk
smhdk / rxjava-skip-operator-example.kt
Last active Dec 4, 2018
RxJava Skip Operator Example with Kotlin
View rxjava-skip-operator-example.kt
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")
}
You can’t perform that action at this time.