Bacho Kurtanidze
10/28/2019, 9:46 AMpietro.scarampella
10/28/2019, 9:55 AMtseisel
10/28/2019, 10:01 PMsealed class ApiResponse<T> {
object Loading : ApiResponse<Nothing>()
class Success<T>(val data: T) : ApiResponse<T>()
class Error(error: Throwable) : ApiResponse<Nothing>()
}
This way, you can check which implementation you have received from LiveData
and update UI accordingly, having only state (data or error) that is relevant.Aslam Hossin
10/29/2019, 2:14 AMSingleTransformer
for ViewModel
by adding compose operator in your ViewModel
through UI component like Activity
or Fragment
.
On the other hand, if you use coroutines
then use a Sealed class
for managing your