darkmoon_uk
08/07/2019, 1:59 PMChannel<ActionEvent>
from a Button
? Is there an established library that already implements these kinds of Coroutines wrappings for JavaFX?Dominaezzz
08/07/2019, 2:10 PM@ExperimentalCoroutinesApi
fun Button.actionEvents(scope: CoroutineScope) : Channel<ActionEvent> {
val actionEvents = Channel<ActionEvent>(Channel.UNLIMITED)
this@actionEvents.onAction = EventHandler { actionEvent ->
actionEvents.offer(actionEvent)
}
actionEvents.invokeOnClose {
this@actionEvents.onAction = null
}
return actionEvents
}
launch
is a bit heavy for this.darkmoon_uk
08/07/2019, 2:20 PMoffer
, good to know 👍