Hey all, for a personal project I implemented a `S...
# tornadofx
Hey all, for a personal project I implemented a
class which allows you to invoke a
suspendingAction { }
block as a coroutine replacement for
asyncAction { }
(i.e. the block gives you a CoroutineScope for invoking suspending functions). It also auto-cancels launched coroutines if the view is undocked. Is this something anyone else would be interested in? If so, what’s the best way to contribute this back to the TornadoFX project? Here’s the current implementation in my project: https://github.com/emanguy/GitlabTimeTracker/blob/master/src/main/kotlin/ui/util/SuspendingView.kt And here’s somewhere I use it to call suspending functions: https://github.com/emanguy/GitlabTimeTracker/blob/master/src/main/kotlin/ui/view/LoginView.kt#L33
👍 1
❤️ 1
I think pull request is the usual way to do that. It allows for review and discussion.
Agree here, pls make a pull request. Also, for the controller and other non-UI ops - it's a bad idea to use the Dispatchers.Default, instead consider wrapping the existing threadpools in tornadoFx into a ExecutorCoroutineDispatcher and using that
Why is it bad to use Dispatchers.Default in a controller? Can you expand on that a bit more? I assume Controllers are generally doing business logic so if they need to touch UI stuff for any reason they can just withContext onto the JavaFx dispatcher