Skip to content

Instantly share code, notes, and snippets.

@bolaware
Created June 17, 2019 22:16
Show Gist options
  • Save bolaware/19c0ae28a0292d7130862bdf5242da27 to your computer and use it in GitHub Desktop.
Save bolaware/19c0ae28a0292d7130862bdf5242da27 to your computer and use it in GitHub Desktop.
data class Result<out T>(val status: Status, val data: T?, val message: String?, val code : Int = 0) {
companion object {
fun <T> success(data: T?): Resource<T> {
return Result(Status.SUCCESS, data, null)
}
fun <T> error(msg: String, data: T?): Resource<T> {
return Result(Status.ERROR, data, msg)
}
fun <T> loading(data: T?): Resource<T> {
return Result(Status.LOADING, data, null)
}
}
}
enum class Status {
SUCCESS,
ERROR,
LOADING,
FAILURE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment