Created
March 3, 2020 10:56
-
-
Save Urdzik/5c2d1505c63f7ed89b0aa53075cbad58 to your computer and use it in GitHub Desktop.
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 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