Joan Colmenero
07/04/2019, 9:56 PMEither
class as a result of my Service
sealed class Either<out L, out R> {
class Left<out L>(val a: L) : Either<L, Nothing>()
class Right<out R>(val b: R) : Either<Nothing, R>()
val isRight get() = this is Right<R>
val isLeft get() = this is Left<L>
fun <L> left(a: L) = Left(a)
fun <R> right(b: R) = Right(b)
fun either(fnL: (L) -> Any, fnR: (R) -> Any): Any =
when (this) {
is Left -> fnL(a)
is Right -> fnR(b)
}
}
And the result of my service is Single<Either<Failure,List<MyClass>>
so, my question is, if I do this :
disposable = getPews.execute(pews)
.subscribeOn(<http://Schedulers.io|Schedulers.io>())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ result ->
},
{ error ->
})