Last active
October 12, 2021 14:53
-
-
Save ArunYogeshwaran/fc6c8209ce19be85c235197fbea2015e to your computer and use it in GitHub Desktop.
Sealed class representing all the possible UI states
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
/** | |
* Represents the UI state of a long running operation. | |
*/ | |
sealed class UIState<out Int> { | |
/** | |
* Indicates the operation succeeded. | |
*/ | |
object Success : UIState<Nothing>() | |
/** | |
* Indicates the operation is going on with a loading message ID. | |
* | |
* @param loadingMessageId The ID to find the string resource. | |
*/ | |
class Loading(@StringRes val loadingMessageId: Int) : UIState<Int>() | |
/** | |
* Indicates the operation failed with an error message ID. | |
* | |
* @param errorMessageId The ID to find the string resource. | |
*/ | |
class Error(@StringRes val errorMessageId: Int) : UIState<Int>() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment