Created
June 17, 2019 22:16
-
-
Save bolaware/19c0ae28a0292d7130862bdf5242da27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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