``` sealed class Response data class Success(val b...
# android
m
Copy code
sealed class Response
data class Success(val body : Data) : Response
data class Failure(val error : Throwable) : Response
...
if (res is Success) {
    updateUi(res.body)
}
t
this is how I like to do all my network calls where the logic that handles them is inside an
Observable.Transformer
l
fold that thing! ­čÖé
Copy code
fun <T> Response.fold(failure: (Throwbable) -> T, success: (Data) -> T) = when(this) {
    is Success -> success(data)
    is Failure -> failure(error) 
}