andrewreitz
02/09/2021, 7:30 PMButton(
onClick = { runit() }
) {
Text("Run")
}
Where runit is the suspend function. I can put it in a runBlocking, but that locks up the whole UI and seems incorrect in this situation.jim
02/09/2021, 8:02 PMrunit()
is a suspending function, but yeah, if it's a potentially slow function, you should probably launch
it into a new thread or coroutine scope. https://kotlinlang.org/docs/reference/coroutines/basics.htmlandrewreitz
02/09/2021, 9:24 PMfun main = Window() { }
Is there a scope build for the window already?jim
02/09/2021, 9:30 PMGlobalScope
since you typically don't want the action to suddenly die if the user switches tabs or the widget is otherwise removed from the hierarchy.andrewreitz
02/10/2021, 2:55 PMrunBlocking
just uses global scope right? So I could maybe do runBlocking { Window() { ... } }
then I should be able to use launch and async inside the window block? Seems like it might be nice if window had a context even if it was just global.