Class ReactfxUtil


  • public final class ReactfxUtil
    extends java.lang.Object
    Extensions to ReactFX Val and EventStreams. Some can be deemed as too general for this project: I'd like them to be moved to the reactfx main project -> but it's unmaintained.
    Author:
    Clément Fournier
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends javafx.event.Event>
      org.reactfx.Subscription
      addEventHandler​(javafx.beans.property.Property<javafx.event.EventHandler<T>> addMethod, javafx.event.EventHandler<T> handler)  
      static <T extends javafx.event.Event>
      org.reactfx.Subscription
      addEventHandler​(javafx.scene.Node node, javafx.event.EventType<T> type, javafx.event.EventHandler<T> handler)  
      static org.reactfx.value.Var<java.lang.Boolean> booleanVar​(javafx.beans.property.BooleanProperty p)  
      static <I> org.reactfx.EventStream<I> distinctBetween​(org.reactfx.EventStream<I> input, java.time.Duration duration)  
      static <T> org.reactfx.value.Val<T> latestValue​(org.reactfx.EventStream<T> values)
      Converts an event stream to a val, that always holds the latest emitted value of the stream.
      static <T> org.reactfx.EventStream<T> reduceEntangledIfPossible​(org.reactfx.EventStream<T> input, java.util.function.BiPredicate<T,​T> canReduce, java.util.function.BinaryOperator<T> reduction, java.time.Duration duration)
      Like reduce if possible, but can be used if the events to reduce are emitted in extremely close succession, so close that some unrelated events may be mixed up.
      static <T> org.reactfx.Subscription rewire​(javafx.beans.property.Property<T> underlying, javafx.beans.value.ObservableValue<? extends T> source)
      Like rewireInit, with no initialisation.
      static <T> org.reactfx.Subscription rewireInit​(javafx.beans.property.Property<T> underlying, javafx.beans.property.Property<T> ui)
      Like the other overload, using the setter of the ui property.
      static <T> org.reactfx.Subscription rewireInit​(javafx.beans.property.Property<T> underlying, javafx.beans.value.ObservableValue<? extends T> ui, java.util.function.Consumer<? super T> setter)
      Binds the underlying property to a source of values (UI property).
      static <T> org.reactfx.Subscription subscribeDisposable​(javafx.beans.value.ObservableValue<? extends T> obs, java.util.function.Function<? super T,​org.reactfx.Subscription> subscriber)
      Subscribe to the values of the given observable, with a function that needs unsubscription when the value changes.
      static <T> org.reactfx.Subscription subscribeDisposable​(org.reactfx.EventStream<T> stream, java.util.function.Function<T,​org.reactfx.Subscription> subscriber)  
      static <T> org.reactfx.value.Val<T> vetoableNull​(org.reactfx.value.Val<T> base, java.time.Duration duration)  
      static org.reactfx.value.Val<java.lang.Boolean> vetoableYes​(org.reactfx.value.Val<java.lang.Boolean> base, java.time.Duration vetoPeriod)
      Returns a val that reflects "true" values of the input val only after the [vetoPeriod], and only if they're not vetoed by a "false" value emitted during the veto period.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • subscribeDisposable

        public static <T> org.reactfx.Subscription subscribeDisposable​(javafx.beans.value.ObservableValue<? extends T> obs,
                                                                       java.util.function.Function<? super T,​org.reactfx.Subscription> subscriber)
        Subscribe to the values of the given observable, with a function that needs unsubscription when the value changes.
      • subscribeDisposable

        public static <T> org.reactfx.Subscription subscribeDisposable​(org.reactfx.EventStream<T> stream,
                                                                       java.util.function.Function<T,​org.reactfx.Subscription> subscriber)
      • addEventHandler

        public static <T extends javafx.event.Event> org.reactfx.Subscription addEventHandler​(javafx.beans.property.Property<javafx.event.EventHandler<T>> addMethod,
                                                                                              javafx.event.EventHandler<T> handler)
      • addEventHandler

        public static <T extends javafx.event.Event> org.reactfx.Subscription addEventHandler​(javafx.scene.Node node,
                                                                                              javafx.event.EventType<T> type,
                                                                                              javafx.event.EventHandler<T> handler)
      • distinctBetween

        public static <I> org.reactfx.EventStream<I> distinctBetween​(org.reactfx.EventStream<I> input,
                                                                     java.time.Duration duration)
      • latestValue

        public static <T> org.reactfx.value.Val<T> latestValue​(org.reactfx.EventStream<T> values)
        Converts an event stream to a val, that always holds the latest emitted value of the stream.
      • vetoableYes

        public static org.reactfx.value.Val<java.lang.Boolean> vetoableYes​(org.reactfx.value.Val<java.lang.Boolean> base,
                                                                           java.time.Duration vetoPeriod)
        Returns a val that reflects "true" values of the input val only after the [vetoPeriod], and only if they're not vetoed by a "false" value emitted during the veto period. "false" values are reflected immediately.
      • vetoableNull

        public static <T> org.reactfx.value.Val<T> vetoableNull​(org.reactfx.value.Val<T> base,
                                                                java.time.Duration duration)
      • rewireInit

        public static <T> org.reactfx.Subscription rewireInit​(javafx.beans.property.Property<T> underlying,
                                                              javafx.beans.property.Property<T> ui)
        Like the other overload, using the setter of the ui property.
      • rewireInit

        public static <T> org.reactfx.Subscription rewireInit​(javafx.beans.property.Property<T> underlying,
                                                              javafx.beans.value.ObservableValue<? extends T> ui,
                                                              java.util.function.Consumer<? super T> setter)
        Binds the underlying property to a source of values (UI property). The UI property is also initialised using a setter.
        Type Parameters:
        T - Type of values
        Parameters:
        underlying - The underlying property
        ui - The property exposed to the user (the one in this wizard)
        setter - Setter to initialise the UI value
      • rewire

        public static <T> org.reactfx.Subscription rewire​(javafx.beans.property.Property<T> underlying,
                                                          javafx.beans.value.ObservableValue<? extends T> source)
        Like rewireInit, with no initialisation.
      • booleanVar

        public static org.reactfx.value.Var<java.lang.Boolean> booleanVar​(javafx.beans.property.BooleanProperty p)
      • reduceEntangledIfPossible

        public static <T> org.reactfx.EventStream<T> reduceEntangledIfPossible​(org.reactfx.EventStream<T> input,
                                                                               java.util.function.BiPredicate<T,​T> canReduce,
                                                                               java.util.function.BinaryOperator<T> reduction,
                                                                               java.time.Duration duration)
        Like reduce if possible, but can be used if the events to reduce are emitted in extremely close succession, so close that some unrelated events may be mixed up. This reduces each new event with a related event in the pending notification chain instead of just considering the last one as a possible reduction target.