Skip to content

Instantly share code, notes, and snippets.

@ArunYogeshwaran
Last active October 12, 2021 14:53
Show Gist options
  • Save ArunYogeshwaran/fc6c8209ce19be85c235197fbea2015e to your computer and use it in GitHub Desktop.
Save ArunYogeshwaran/fc6c8209ce19be85c235197fbea2015e to your computer and use it in GitHub Desktop.
Sealed class representing all the possible UI states
/**
* 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