Open msink opened 6 years ago
Is it possible to use Coroutines with Kotlin-libui in Linux application? My code doesn't work.
fun main() = runBlocking {
appWindow(
title = "Coroutine",
width = 500,
height = 500
) {
vbox {
button("Launch Coroutine") {
action {
async(Dispatchers.Main) {
printSomething()
}
}
}
}
}
}
suspend fun printSomething() {
println("Run");
}
How does it not work?
When I click on the Button, nothing happens. After closing the Box, "Run" is printed.
Dispatchers.Main
hasn't been implemented yet for kotlin-libui
.
Is it difficult to implement it myself? do you have any resources or sample code?
You can implement you own Dispatcher
. This might help.
Need to integrate coroutines support from https://github.com/Kotlin/kotlinx.coroutines/tree/master/native and add sample similar to
timer
but based on coroutines.