<@U2E974ELT> Just out of curiosity - how does one ...
# coroutines
a
@elizarov Just out of curiosity - how does one go about adding support for 'suspend' functions to their own interface of their library - dunno if the question makes sense --- https://twitter.com/JakeWharton/status/964556938322341894
👍 1
g
What do you mean? Of course only one who wants to use suspend Retrofit method would add it to interface. This tweet about support of such approach from side of Retrofit
a
Right yeah thats what I mean - what would the support from retrofit's side look like
g
Retrofit uses reflection and creates Proxy instances. So I suppose it should somehow detect suspend functions and generate proper Proxy instance for suspend functions
j
Yes, that. It's a mechanism for detecting the Continuation parameter and hooking it up.
Except in a general way and not just hardcoding explicit support
g
In a general way? What do you mean? Allow to support not only kotlin.coroutines Continuations?
j
Retrofit 1 allowed a callback as the last parameter of a method signature. So the idea is to build a mechanism similar to CallAdapters that allows adapting the last parameter into another type.
So you'd install a CallbackAdapter that adapted a Continuation into retrofit's Callback which was then enqueued automatically before returning
g
I see. And then just provide this parameter adapter for coroutines continuation
yes, got it