Has anyone used kotlinx.coroutine `Flow`s with Jav...
# tornadofx
d
Has anyone used kotlinx.coroutine `Flow`s with JavaFX. In particular, converting them to `ObservableValue`s.
d
is there a specific reason not to use RxJavaFX ?
d
I've never used Rx but I'm very familiar with
kotlinx.coroutines
.
a
There is a backwards converter: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-javafx/kotlinx.coroutines.javafx/javafx.beans.value.-observable-value/index.html. I am not sure it makes sense to convert a Flow to a value. Do you have some specific case in mind?
d
I have a property and I want to perform map and filter operations on it, then give the result to a UI component. I thought using a flow in the middle would be the way to go.
a
Yeah, but I think it is easier to perform collect operation in the end of the flow and update the property. Of course, it is quite easy to implement Obsevable value with flow: https://docs.oracle.com/javafx/2/api/javafx/beans/value/ObservableValue.html
d
I ended up implementing one (using RxJavaFx as a guide), it works but I'm not sure if it's..... good.
a
It is basically just a value with observer. The only difference is that you need to provide a scope for it. You call collect on a flow in coroutine and update all listeners.