An initial experimental implementation of `kotlinx...
# webassembly
i
An initial experimental implementation of
kotlinx.coroutines
version
1.8.0-RC2-wasm0
for
WASI
was published into the experimental repo. To be compatible with current 1.9.20 toolchain one have to wrap main function into
runEventLoop
function call, like:
Copy code
// main or other "root" function
fun main() = kotlinx.coroutines.runEventLoop {
    GlobalScope.launch { 
        // suspend function call
    }
}
A coroutine test, that uses ``kotlinx.coroutines.test`` can be written as usual, like:
Copy code
@Test
fun myTest() = kotlinx.coroutines.test.runTest {
    // suspend function call
}
K 4
🚀 2
⏸️ 4
b
@sdeleuze JFYI
👍 1
h
Can you provide some technical details, how did you solve the missing platform apis? Looking at the source code its is a single "thread"/event loop solution using global variables.
i
Yes. It is single thread event loop. Delayed coroutine uses blocking timer. As far as wasm is single-threaded now this is the only solution we see.