Hi everyone! Is there anyone working with Reaktiv...
# reaktive
l
Hi everyone! Is there anyone working with Reaktive and JavaFX? I need a JavaFX Scheduler. Thanks!
a
It should be pretty easy to implement
Scheduler
by using
Platform.runLater
. For delayed operations you can post to a thread pool and then again use
runLater
. Just be careful with cancellations - a cancelled
Executor
must not call any previously submitted callbacks. I could create an example if needed. Alternatively, you can use kotlinx-coroutines-javafx and Reaktive
coroutines-interop
modules and do as follows:
Copy code
val uiScheduler = Dispatchers.Main.asScheduler()
l
Ok. got some "inspiration" from the newThreadScheduler. Created an executor from
Copy code
Executors.newScheduledThreadPool(1) { runnable ->
    Thread(runnable).apply {
        isDaemon = true
    }
}
The tasks from submit() and submitRepeating() were wrapped using Platform.runLater. Something like this?
a
Yeah something like this! Just make sure, when an instance of
Scheduler.Executor
is cancelled/disposed, none of its scheduled tasks hould be ever executed.