On rare occasions, you may find yourself having to pass an Observable
to another API that converts it into a proprietary type. This can be done simply by passing an Observable
as an argument to a factory that does this conversion. However, this does not always feel fluent, and this is where the to()
operator comes in.
For example, JavaFX has a Binding<T>
type that houses a mutable value of type T
, and it will notify affected user interface elements to update when it changes. RxJavaFX has JavaFxObserver.toBinding()
and JavaFxSubscriber.toBinding()
factories, which can turn an Observable<T>
or Flowable<T>
into a JavaFX Binding<T>
. Here is a simple JavaFX Application
that uses Binding<String>
built-off Observable<String>
, which is used to bind to a textProperty()
operator of label
:
import io.reactivex.Observable; import io.reactivex.rxjavafx.observers.JavaFxObserver; import io.reactivex.rxjavafx.schedulers.JavaFxScheduler...