Last active
November 15, 2019 17:37
-
-
Save gastsail/0c3fec96477dd6f7acc538206110429a to your computer and use it in GitHub Desktop.
Resource
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 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