Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Created April 21, 2020 10:10
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 PatilShreyas/e058a01b400e38fd874eb1dbb61d2c6f to your computer and use it in GitHub Desktop.
Save PatilShreyas/e058a01b400e38fd874eb1dbb61d2c6f to your computer and use it in GitHub Desktop.
sealed class State<T> {
class Loading<T> : State<T>()
data class Success<T>(val data: T) : State<T>()
data class Failed<T>(val message: String) : State<T>()
companion object {
fun <T> loading() = Loading<T>()
fun <T> success(data: T) = Success(data)
fun <T> failed(message: String) = Failed<T>(message)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment