Skip to content

Instantly share code, notes, and snippets.

@pablobaldez
Created March 7, 2021 23:58
Show Gist options
  • Save pablobaldez/f12cedd226b7d4b2cbf790fd56ec4bb4 to your computer and use it in GitHub Desktop.
Save pablobaldez/f12cedd226b7d4b2cbf790fd56ec4bb4 to your computer and use it in GitHub Desktop.
A generic class that contains data and status about loading this data.
sealed class Resource<T>(
val data: T?
) {
class Success<T>(data: T) : Resource<T>(data)
class Loading<T>(data: T? = null) : Resource<T>(data)
class Error<T>(throwable: Throwable, data: T? = null) : Resource<T>(data)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment