kotlin-libui icon indicating copy to clipboard operation
kotlin-libui copied to clipboard

Coroutines

Open msink opened this issue 7 years ago • 6 comments

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.

msink avatar Nov 28 '18 01:11 msink

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");
}

abbas-oveissi avatar Aug 05 '19 16:08 abbas-oveissi

How does it not work?

Dominaezzz avatar Aug 05 '19 16:08 Dominaezzz

When I click on the Button, nothing happens. After closing the Box, "Run" is printed.

abbas-oveissi avatar Aug 05 '19 16:08 abbas-oveissi

Dispatchers.Main hasn't been implemented yet for kotlin-libui.

Dominaezzz avatar Aug 05 '19 16:08 Dominaezzz

Is it difficult to implement it myself? do you have any resources or sample code?

abbas-oveissi avatar Aug 05 '19 16:08 abbas-oveissi

You can implement you own Dispatcher. This might help.

Dominaezzz avatar Aug 05 '19 17:08 Dominaezzz