Created
October 21, 2018 20:46
-
-
Save hadilq/a5c533d2613f1ecf1c76f12f592a6ae4 to your computer and use it in GitHub Desktop.
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
/** | |
* A wrapper for database and network states. | |
*/ | |
sealed class ResultState<T> { | |
/** | |
* A state of [data] which shows that we know there is still an update to come. | |
*/ | |
data class Loading<T>(val data: T) : ResultState<T>() | |
/** | |
* A state that shows the [data] is the last known update. | |
*/ | |
data class Success<T>(val data: T) : ResultState<T>() | |
/** | |
* A state to show a [throwable] is thrown beside the [lastData] which is cached. | |
*/ | |
data class Error<T>(val throwable: Throwable, val lastData: T?) : ResultState<T>() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment