Last active
March 5, 2020 15:10
-
-
Save UdiOshi85/a7892628e022ec5aeaaf70c12e014027 to your computer and use it in GitHub Desktop.
LiveData Resource class
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 actionType: Int, val data: T?, val payload: Bundle?) { | |
companion object { | |
fun <T> success(actionType: Int, data: T? = null, payload: Bundle? = null): Resource<T> { | |
return Resource(Status.SUCCESS,actionType, data, payload) | |
} | |
fun <T> error(actionType: Int, data: T? = null, payload: Bundle? = null): Resource<T> { | |
return Resource(Status.ERROR, actionType, data, payload) | |
} | |
fun <T> loading(actionType: Int, data: T? = null, payload: Bundle? = null): Resource<T> { | |
return Resource(Status.LOADING, actionType, data, payload) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment