Advertisement
Nicba1010

Retrofit enqueue

May 2nd, 2020
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.44 KB | None | 0 0
  1. inline fun <reified T> Call<T>.enqueue(
  2.     crossinline onResponse: (Call<T>, Response<T>) -> Unit,
  3.     crossinline onFailure: (Call<T>, Throwable) -> Unit
  4. ) {
  5.     return this.enqueue(object : Callback<T> {
  6.         override fun onResponse(call: Call<T>, response: Response<T>) {
  7.             onResponse(call, response)
  8.         }
  9.  
  10.         override fun onFailure(call: Call<T>, t: Throwable) {
  11.             onFailure(call, t)
  12.         }
  13.     })
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement