Created
June 29, 2019 21:05
-
-
Save psteiger/4d3c61b3250b074162263e627d4e9be4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| fun <T> Resource<T>.onSuccess( | |
| onSuccess: (data: T) -> Unit | |
| ): Resource<T> { | |
| if (this is Resource.Success<T>) | |
| onSuccess(data) | |
| return this | |
| } | |
| fun <T> Resource<T>.onLoading( | |
| onLoading: (partialData: T?) -> Unit | |
| ): Resource<T> { | |
| if (this is Resource.Loading) | |
| onLoading(partialData) | |
| return this | |
| } | |
| fun <T> Resource<T>.onFailure( | |
| onFailure: (throwable: Throwable?) -> Unit | |
| ): Resource<T> { | |
| if (this is Resource.Failure) | |
| onFailure(throwable) | |
| return this | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment