JavaFX has the concept of observable property, so ...
# coroutines
r
JavaFX has the concept of observable property, so for example having
val boolProperty = SimpleBooleanProperty()
you can get current value, set new value and listen for changes in it. TornadoFX, which is Kotlin library based on JavaFX, has the following neat feature: https://github.com/edvin/tornadofx-guide/blob/master/part2/Property%20Delegates.md#alternative-property-syntax Basically they allow you to use Kotlin's delegated property to wrap
SimpleBooleanProperty
into
var bool: Boolean by boolProperty
having delegated getter and setter. To me observable properties seem to be similar to
ConflatedChannel
. Does the following make sense?
Copy code
operator fun <E> ConflatedBroadcastChannel<E>.getValue(thisRef: Any, property: KProperty<*>) = this.value
operator fun <E> ConflatedBroadcastChannel<E>.setValue(thisRef: Any, property: KProperty<*>, value: E) = send(value)
If so, is this a candidate for
kotlinx.coroutines
or this is something too use-case-specific for the library?