Simple code

This commit is contained in:
Benoit Marty 2019-08-05 15:09:06 +02:00
parent dafdc1d3ad
commit 1462fa0484

View File

@ -31,3 +31,11 @@ inline fun <A> TryOf<A>.onError(f: (Throwable) -> Unit): Try<A> = fix()
fun <A> Try<A>.foldToCallback(callback: MatrixCallback<A>): Unit = fold( fun <A> Try<A>.foldToCallback(callback: MatrixCallback<A>): Unit = fold(
{ callback.onFailure(it) }, { callback.onFailure(it) },
{ callback.onSuccess(it) }) { callback.onSuccess(it) })

/**
* Same as doOnNext for Observables
*/
inline fun <A> Try<A>.alsoDo(f: (A) -> Unit) = map {
f(it)
it
}