Skip to content

Instantly share code, notes, and snippets.

@Urdzik
Created March 3, 2020 10:56
Show Gist options
  • Save Urdzik/5c2d1505c63f7ed89b0aa53075cbad58 to your computer and use it in GitHub Desktop.
Save Urdzik/5c2d1505c63f7ed89b0aa53075cbad58 to your computer and use it in GitHub Desktop.
val zip = BiFunction<Boolean, Boolean, Boolean> { t1, t2 -> t1 == t2 }
val bool1 =
Flowable.fromArray(true, false, true, false, false)
val bool2 =
Flowable.fromArray(false, true, true, false, true).zipWith(bool1, zip).subscribeOn(
Schedulers.io()).onErrorReturn { t: Throwable ->
eLog(t)
false
}
val range =
Flowable.interval(500, TimeUnit.MICROSECONDS).take(5).filter { x -> x % 2L == 0L }
.subscribeOn(Schedulers.computation()).observeOn(Schedulers.newThread())
val a = bool2.subscribe(
{ bool ->
if (bool) {
range.subscribe({
if (it != 0L) {
logN(1 / it.toDouble())
}
}, {
eLog(it)
}, {
log("Ура!")
})
} else {
log(" ")
}
},
{
eLog(it)
}
)
}
private fun log(s: String) {
Log.i("TAG", s)
}
private fun logN(s: Double) {
Log.i("TAGN", s.toString())
}
private fun eLog(e: Throwable) {
Log.e("TAG", e.toString())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment