https://kotlinlang.org logo
#javascript
Title
# javascript
i

Ivan Đorđević

03/14/2023, 1:32 PM
Is there a way to make Kotlin/JS useful (and not have to create wrappers for all suspend functions for example) with the IR compiler? Is there an experimental toggle/feature somehow that would make them work with
@JsExport
or generate promises out of them automatically?
t

turansky

03/14/2023, 8:06 PM
Do you need cancellable
Promise
s? In which coroutine context
suspend
function must be called inside
Promise
?
r

Roland Hediger

03/15/2023, 2:58 PM
I assume more concretely this means the dev wants to expose a suspend function to normal JS as part of the API of their library developed in Kotlin Multiplatform. So when the function of the library is invoked from JS, since javascript does not understand suspend it would recognise the function exposed by the library as a function with the return value of
Promise
.My company would also be interested in such a feature.
t

turansky

03/15/2023, 3:17 PM
My company would also be interested in such a feature.
Details required
Do you need cancellable
Promise
s?
In which coroutine context
suspend
function must be called inside
Promise
?
r

Roland Hediger

03/15/2023, 3:18 PM
I would not need them to be cancellable, I could see that as a more complete version of the feature for all cases, but it would be nice to just have the promise cover the success and error cases for the purposes of my company. As I would expose the function to the JS user, the JS user would have no way to call any suspend functions inside the promise.
👍 1
2 Views