hi, do you know if we can use coroutines with JS/I...
# javascript
m
hi, do you know if we can use coroutines with JS/IR in TypeScript? From what I see we cannot use
suspend
functions, but with
Flow
I've got
d.ts
result like:
longAdd(a: number, b: number): kotlinx.coroutines.flow.Flow<number>;
. Any idea if we can use it?
a
You still can't. You'll need a suspend function to collect the flow. However you can expose a promise and use that from Typescript
m
tried that, but when exporting:
Copy code
@JsExport
fun fooPromise(): Promise<String> = GlobalScope.promise {
    delay(2000)
    "sth"
}
I've got
d.ts
as:
Copy code
export function fooPromise(): kotlin.js.Promise<string>;
which doesn't seem to work
or maybe I need to add kotlin.js.Promise dependency to TS project
a
That looks like a bug. You should file it
m
fun thing, when I just removed
kotlin.js.
before Promise i d.ts it works
works, like I can use this promise
a
Nice going there