Skip to content

Instantly share code, notes, and snippets.

@Nimrodda
Created April 14, 2020 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nimrodda/a61c313b3b049b6f8a7c8826d7e2fb69 to your computer and use it in GitHub Desktop.
Save Nimrodda/a61c313b3b049b6f8a7c8826d7e2fb69 to your computer and use it in GitHub Desktop.
sealed class ViewState<T>(val data: T? = null) {
class Loading<T>(data: T? = null) : ViewState<T>(data)
class Error<T>(val throwable: Throwable, data: T? = null) : ViewState<T>(data)
class Loaded<T>(data: T? = null) : ViewState<T>(data)
fun isLoading(): Boolean = this is Loading
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment