If I understand correctly, there is no ‘nice' way ...
# coroutines
c
If I understand correctly, there is no ‘nice' way to call suspend functions from JS, Java & other languages. Would it be possible to have a compiler plugin/code generation thing that would create an equivalent of each public suspend function, that wraps it into a
Promise
for JS, and an equivalent for other platforms? I'm making a library to access a web service, and it doesn't feel right to add all of those functions by hand, I guess there's a better way?
s
Wrap everything coming into you library in a scope and use a callback for the response.
r
If I understand correctly, there is no ‘nice' way to call suspend functions from JS, Java & other languages.
At least Kotlin/Native would come with a way to access suspend functions out of the box from Objective-C / Swift, as these would translate to usual methods with continuation lambdas. I don't know if similar is planned to be implemented for Kotlin/JVM or Kotlin/JS though.
Would it be possible to have a compiler plugin/code generation thing that would create an equivalent of each public suspend function, that wraps it into a 
Promise
 for JS, and an equivalent for other platforms?
Sure, though I don't know any ready-to-use solution for that. Compiler plugin sounds more reasonable solution, but as you may know, API isn't stable and won't become such in 1.4.
c
Oh, same issue as Arrow Meta then. Well, I think I saw that the ETA was a few months now? My product won't be ready before that anyway, so I'll wait 👍
r
I personally doubt compiler API would be here this year, so it's quite broad assumption to rely on it's availability. On the other hand, nothing prevents one to develop such solution right now -- it's just more work since no documentation exists and one would have to update the solution from version to version. But if no one publicly mentioned his / her will to work on that -- it's also unreasonable to rely on it.
TL;DR (my stance, ofc): you either find out someone working on that (unlikely), work on that yourself, or don't rely on that and write your wrappers manually 🙂
c
Thanks for the info, I'll consider that 👍