Created
April 10, 2021 13:29
-
-
Save ajailani4/cad54d6308b864508318d0599576fa24 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 Resource<out T>(val status: Status, val data: T?, val message: String?) { | |
companion object { | |
fun <T> loading(data: T?): Resource<T> { | |
return Resource(Status.LOADING, data, null) | |
} | |
fun <T> success(data: T?): Resource<T> { | |
return Resource(Status.SUCCESS, data, null) | |
} | |
fun <T> error(message: String?, data: T?): Resource<T> { | |
return Resource(Status.ERROR, data, message) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment