https://kotlinlang.org logo
#ktor
Title
# ktor
c

crummy

03/05/2021, 8:31 PM
I'm trying to build a simple ktor client that I can use in my JS code. But the client is coroutine heavy, and @JsExport doesn't work with coroutines. Is there a way to do this?
t

turansky

03/05/2021, 8:45 PM
exported
suspend
method is bug.
suspend
methods - Kotlin specific (non-exportable) But in any case you need methods, which will return
Promise
instead
Could you mark
suspend
methods with
internal
(for WA)?
Do you use
IR
?
c

crummy

03/06/2021, 5:34 AM
Yeah, using IR. So can un-suspend a suspend function by returning a Promise somehow?
j

Jurriaan Mous

03/06/2021, 6:46 AM
I made in the jsMain source sets implementations of the api calls in the following way to return a promise from a suspending function: fun acceptTerms( version: String, ) = GlobalScope.promise { package.acceptTerms( httpClient, AcceptTermsRequest(version) ) }
👍 2