Created
August 5, 2019 14:15
-
-
Save HarryTylenol/6f41bb3fb77dab685e6522fd4d96781c to your computer and use it in GitHub Desktop.
0003_2
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
// ResponseWrapper | |
data class ResponseWrapper<T>( | |
val data: LiveData<T>, | |
val state: LiveData<NetworkState>, | |
val refreshState: LiveData<NetworkState>, | |
val refresh: () -> Unit | |
) | |
// NetworkState | |
sealed class NetworkState { | |
override fun toString(): String { | |
return when (this) { | |
is success -> "NetworkState.success" | |
is failed -> "NetworkState.failed : ${error?.message}" | |
is loading -> "NetworkState.loading" | |
} | |
} | |
object success : NetworkState() | |
class failed(val error: Throwable? = null) : NetworkState() | |
object loading : NetworkState() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment