Skip to content

Instantly share code, notes, and snippets.

@yongjhih
Last active April 12, 2024 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yongjhih/42c3a391ac2fdf8032eea429222cc08c to your computer and use it in GitHub Desktop.
Save yongjhih/42c3a391ac2fdf8032eea429222cc08c to your computer and use it in GitHub Desktop.
fun <R> TypeAdapter<R>.convertResponse(onConvert: TypeAdapter<R>.(ResponseBody) -> R): Converter<ResponseBody, R> =
Converter<ResponseBody, R> { onConvert(it) }
fun <T> TypeAdapter<T>.convertRequest(onConvert: TypeAdapter<T>.(T) -> RequestBody): Converter<T, RequestBody> =
Converter<T, RequestBody> { onConvert(it) }
fun <T, R, I : Converter<in T, out R>> I.wrap(onConvert: I.(T) -> R): Converter<T, R> =
Converter<T, R> { this@wrap.onConvert(it) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment