Use Retrofit methods more expressive way

this is how i do it with extension function and a class fun<T> Call<T>.enqueue(callback: CallBackKt<T>.() -> Unit) { val callBackKt = CallBackKt<T>() callback.invoke(callBackKt) this.enqueue(callBackKt) } class CallBackKt<T>: Callback<T> { var onResponse: ((Response<T>) -> Unit)? = null var onFailure: ((t: Throwable?) -> Unit)? = null override fun onFailure(call: Call<T>, t: Throwable) { onFailure?.invoke(t) } override fun … Read more

tech