Package kotlinx.coroutines.javafx

Provides Dispatchers.JavaFx context and Dispatchers.Main implementation for JavaFX UI applications.


Link copied to clipboard
sealed class JavaFxDispatcher : MainCoroutineDispatcher, Delay

Dispatcher for JavaFx application thread with support for awaitPulse.


Link copied to clipboard
fun <T> ObservableValue<T>.asFlow(): Flow<T>

Creates an instance of a cold Flow that subscribes to the given ObservableValue and emits its values as they change. The resulting flow is conflated, meaning that if several values arrive in quick succession, only the last one will be emitted. Since this implementation uses ObservableValue.addListener, even if this ObservableValue supports lazy evaluation, eager computation will be enforced while the flow is being collected. All the calls to JavaFX API are performed in Dispatchers.JavaFx. This flow emits at least the initial value.

Link copied to clipboard
suspend fun awaitPulse(): Long

Suspends coroutine until next JavaFx pulse and returns time of the pulse on resumption. If the Job of the current coroutine is completed while this suspending function is waiting, this function immediately resumes with CancellationException.


Link copied to clipboard
val Dispatchers.JavaFx: JavaFxDispatcher

Dispatches execution onto JavaFx application thread and provides native delay support.