Skip to content

Instantly share code, notes, and snippets.

@gastsail
Last active November 15, 2019 17:37
Show Gist options
  • Save gastsail/0c3fec96477dd6f7acc538206110429a to your computer and use it in GitHub Desktop.
Save gastsail/0c3fec96477dd6f7acc538206110429a to your computer and use it in GitHub Desktop.
Resource
data class Resource<out T>(val status: Status, val data: T?, val message: String?) {
companion object {
fun <T> success(data: T?): Resource<T> {
return Resource(Status.SUCCESS, data, null)
}
fun <T> error(msg: String, data: T?): Resource<T> {
return Resource(Status.ERROR, data, msg)
}
fun <T> loading(data: T?): Resource<T> {
return Resource(Status.LOADING, data, null)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment