Created
October 9, 2019 00:23
-
-
Save demonar/ee10b0344a11b203dda84ae1460dd636 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
inline fun <reified T> Call<T>.enqueue(crossinline result: (Result<T>) -> Unit) { | |
enqueue(object: Callback<T> { | |
override fun onFailure(call: Call<T>, error: Throwable) { | |
result(Result.Failure(call, error)) | |
} | |
override fun onResponse(call: Call<T>, response: Response<T>) { | |
result(Result.Success(call, response)) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment