Class ReactfxUtil


  • public final class ReactfxUtil
    extends 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<Boolean> booleanVar​(javafx.beans.property.BooleanProperty p)  
      static <T> org.reactfx.value.Var<T> defaultedVar​(org.reactfx.value.Val<? extends T> defaultValue)  
      static <I> org.reactfx.EventStream<I> distinctBetween​(org.reactfx.EventStream<I> input, Duration duration)  
      static <T> com.github.oowekyala.rxstring.ReactfxExtensions.RebindSubscription<T> emptySub()  
      static <E> org.reactfx.collection.LiveList<E> flattenList​(org.reactfx.value.Val<? extends javafx.collections.ObservableList<E>> base)  
      static <K,​V>
      org.reactfx.value.Val<Map<K,​org.reactfx.collection.LiveList<V>>>
      groupBy​(javafx.collections.ObservableList<? extends V> base, Function<? super V,​? extends K> selector)  
      static org.reactfx.value.Val<Boolean> isPresentProperty​(org.reactfx.value.Val<?> v)  
      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 <I,​O>
      com.github.oowekyala.rxstring.ReactfxExtensions.RebindSubscription<O>
      map​(com.github.oowekyala.rxstring.ReactfxExtensions.RebindSubscription<I> base, Function<O,​I> f)  
      static <T,​S>
      org.reactfx.collection.LiveList<S>
      mapBothWays​(javafx.collections.ObservableList<T> base, Function<T,​S> forward, Function<S,​T> backward)  
      static <E> org.reactfx.EventStream<?> modificationTicks​(javafx.collections.ObservableList<? extends E> list, Function<? super E,​? extends org.reactfx.EventStream<?>> tickProvider)  
      static <K,​V>
      org.reactfx.value.Val<Map<K,​V>>
      observableMapVal​(javafx.collections.ObservableMap<K,​V> map)  
      static <T> org.reactfx.EventStream<T> reduceEntangledIfPossible​(org.reactfx.EventStream<T> input, BiPredicate<T,​T> canReduce, BinaryOperator<T> reduction, 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 subscribeDisposable​(javafx.beans.value.ObservableValue<? extends T> node, Function<? super T,​org.reactfx.Subscription> subscriber)
      Add a hook on the owner window.
      static <T> org.reactfx.Subscription subscribeDisposable​(org.reactfx.EventStream<T> stream, Function<T,​org.reactfx.Subscription> subscriber)  
      static <T> org.reactfx.value.Val<T> vetoableNull​(org.reactfx.value.Val<T> base, Duration duration)  
      static org.reactfx.value.Val<Boolean> vetoableYes​(org.reactfx.value.Val<Boolean> base, 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.
      static <T> org.reactfx.value.Val<T> withInvalidations​(org.reactfx.value.Val<T> base, Function<T,​org.reactfx.EventStream<?>> otherInvalidations)  
    • Method Detail

      • emptySub

        public static <T> com.github.oowekyala.rxstring.ReactfxExtensions.RebindSubscription<T> emptySub()
      • map

        public static <I,​O> com.github.oowekyala.rxstring.ReactfxExtensions.RebindSubscription<O> map​(com.github.oowekyala.rxstring.ReactfxExtensions.RebindSubscription<I> base,
                                                                                                            Function<O,​I> f)
      • isPresentProperty

        public static org.reactfx.value.Val<Boolean> isPresentProperty​(org.reactfx.value.Val<?> v)
      • subscribeDisposable

        public static <T> org.reactfx.Subscription subscribeDisposable​(javafx.beans.value.ObservableValue<? extends T> node,
                                                                       Function<? super T,​org.reactfx.Subscription> subscriber)
        Add a hook on the owner window. It's not possible to do this statically, since at construction time the window might not be set.
      • modificationTicks

        public static <E> org.reactfx.EventStream<?> modificationTicks​(javafx.collections.ObservableList<? extends E> list,
                                                                       Function<? super E,​? extends org.reactfx.EventStream<?>> tickProvider)
      • subscribeDisposable

        public static <T> org.reactfx.Subscription subscribeDisposable​(org.reactfx.EventStream<T> stream,
                                                                       Function<T,​org.reactfx.Subscription> subscriber)
      • defaultedVar

        public static <T> org.reactfx.value.Var<T> defaultedVar​(org.reactfx.value.Val<? extends T> defaultValue)
      • mapBothWays

        public static <T,​S> org.reactfx.collection.LiveList<S> mapBothWays​(javafx.collections.ObservableList<T> base,
                                                                                 Function<T,​S> forward,
                                                                                 Function<S,​T> backward)
      • 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,
                                                                     Duration duration)
      • groupBy

        public static <K,​V> org.reactfx.value.Val<Map<K,​org.reactfx.collection.LiveList<V>>> groupBy​(javafx.collections.ObservableList<? extends V> base,
                                                                                                                 Function<? super V,​? extends K> selector)
      • flattenList

        public static <E> org.reactfx.collection.LiveList<E> flattenList​(org.reactfx.value.Val<? extends javafx.collections.ObservableList<E>> base)
      • observableMapVal

        public static <K,​V> org.reactfx.value.Val<Map<K,​V>> observableMapVal​(javafx.collections.ObservableMap<K,​V> map)
      • withInvalidations

        public static <T> org.reactfx.value.Val<T> withInvalidations​(org.reactfx.value.Val<T> base,
                                                                     Function<T,​org.reactfx.EventStream<?>> otherInvalidations)
      • 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<Boolean> vetoableYes​(org.reactfx.value.Val<Boolean> base,
                                                                 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,
                                                                Duration duration)
      • booleanVar

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

        public static <T> org.reactfx.EventStream<T> reduceEntangledIfPossible​(org.reactfx.EventStream<T> input,
                                                                               BiPredicate<T,​T> canReduce,
                                                                               BinaryOperator<T> reduction,
                                                                               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.