Package org.reactfx

Class EventStreams


  • public class EventStreams
    extends java.lang.Object
    • Constructor Detail

      • EventStreams

        public EventStreams()
    • Method Detail

      • never

        public static <T> EventStream<T> never()
        Returns an event stream that never emits any value.
      • invalidationsOf

        public static EventStream<java.lang.Void> invalidationsOf​(javafx.beans.Observable observable)
        Creates an event stream that emits an impulse on every invalidation of the given observable.
      • repeatOnInvalidation

        public static <O extends javafx.beans.Observable> EventStream<O> repeatOnInvalidation​(O observable)
        Creates an event stream that emits the given observable immediately for every subscriber and re-emits it on every subsequent invalidation of the observable.
      • valuesOf

        public static <T> EventStream<T> valuesOf​(javafx.beans.value.ObservableValue<T> observable)
        Creates an event stream that emits the value of the given ObservableValue immediately for every subscriber and then on every change.
      • nonNullValuesOf

        public static <T> EventStream<T> nonNullValuesOf​(javafx.beans.value.ObservableValue<T> observable)
      • changesOf

        public static <T> EventStream<Change<T>> changesOf​(javafx.beans.value.ObservableValue<T> observable)
      • simpleChangesOf

        public static <T> EventStream<ListModification<? extends T>> simpleChangesOf​(javafx.collections.ObservableList<T> list)
        Use only when the subscriber does not cause list modification of the underlying list.
      • changesOf

        public static <T> EventStream<javafx.collections.SetChangeListener.Change<? extends T>> changesOf​(javafx.collections.ObservableSet<T> set)
      • changesOf

        public static <K,​V> EventStream<javafx.collections.MapChangeListener.Change<? extends K,​? extends V>> changesOf​(javafx.collections.ObservableMap<K,​V> map)
      • sizeOf

        public static <C extends java.util.Collection<?> & javafx.beans.Observable> EventStream<java.lang.Integer> sizeOf​(C collection)
      • sizeOf

        public static EventStream<java.lang.Integer> sizeOf​(javafx.collections.ObservableMap<?,​?> map)
      • create

        private static <T> EventStream<T> create​(java.util.function.Supplier<? extends T> computeValue,
                                                 javafx.beans.Observable... dependencies)
      • eventsOf

        public static <T extends javafx.event.Event> EventStream<T> eventsOf​(javafx.scene.Node node,
                                                                             javafx.event.EventType<T> eventType)
      • eventsOf

        public static <T extends javafx.event.Event> EventStream<T> eventsOf​(javafx.scene.Scene scene,
                                                                             javafx.event.EventType<T> eventType)
      • eventsOf

        public static <T extends javafx.event.Event> EventStream<T> eventsOf​(javafx.scene.control.MenuItem menuItem,
                                                                             javafx.event.EventType<T> eventType)
      • eventsOf

        public static <T extends javafx.event.Event> EventStream<T> eventsOf​(javafx.stage.Window window,
                                                                             javafx.event.EventType<T> eventType)
      • ticks

        public static EventStream<?> ticks​(java.time.Duration interval)
        Returns an event stream that emits periodic ticks. The first tick is emitted after interval amount of time has passed. The returned stream may only be used on the JavaFX application thread.

        As with all lazily bound streams, ticks are emitted only when there is at least one subscriber to the returned stream. This means that to release associated resources, it suffices to unsubscribe from the returned stream.

      • ticks0

        public static EventStream<?> ticks0​(java.time.Duration interval)
        Returns an event stream that emits periodic ticks. The first tick is emitted at time 0. The returned stream may only be used on the JavaFX application thread.

        As with all lazily bound streams, ticks are emitted only when there is at least one subscriber to the returned stream. This means that to release associated resources, it suffices to unsubscribe from the returned stream.

      • ticks

        public static EventStream<?> ticks​(java.time.Duration interval,
                                           java.util.concurrent.ScheduledExecutorService scheduler,
                                           java.util.concurrent.Executor eventThreadExecutor)
        Returns an event stream that emits periodic ticks on the given eventThreadExecutor. The returned stream may only be used from that executor's thread.

        As with all lazily bound streams, ticks are emitted only when there is at least one subscriber to the returned stream. This means that to release associated resources, it suffices to unsubscribe from the returned stream.

        Parameters:
        scheduler - scheduler used to schedule periodic emissions.
        eventThreadExecutor - single-thread executor used to emit the ticks.
      • restartableTicks

        public static EventStream<?> restartableTicks​(java.time.Duration interval,
                                                      EventStream<?> impulse)
        Returns a ticks(Duration) EventStream whose timer restarts whenever impulse emits an event.
        Parameters:
        interval - - the amount of time that passes until this stream emits its next tick
        impulse - - the EventStream that resets this EventStream's internal timer
      • restartableTicks0

        public static EventStream<?> restartableTicks0​(java.time.Duration interval,
                                                       EventStream<?> impulse)
        Returns a ticks0(Duration) EventStream whose timer restarts whenever impulse emits an event. Note: since ticks0(Duration) is used, restarting the timer will make the returned EventStream immediately emit a new tick.
        Parameters:
        interval - - the amount of time that passes until this stream emits its next tick
        impulse - - the EventStream that resets this EventStream's internal timer
      • animationTicks

        public static EventStream<java.lang.Long> animationTicks()
        Returns an event stream that emits a timestamp of the current frame in nanoseconds on every frame. The timestamp has the same meaning as the argument of the AnimationTimer.handle(long) method.
      • animationFrames

        public static EventStream<java.lang.Long> animationFrames()
        Returns a stream that, on each animation frame, emits the duration elapsed since the previous animation frame, in nanoseconds.
      • merge

        @SafeVarargs
        public static <T> EventStream<T> merge​(EventStream<? extends T>... inputs)
        Returns an event stream that emits all the events emitted from any of the inputs. The event type of the returned stream is the nearest common super-type of all the inputs.
        See Also:
        EventStream.or(EventStream)
      • merge

        public static <T> EventStream<T> merge​(javafx.collections.ObservableSet<? extends EventStream<T>> set)
        Returns an event stream that emits all the events emitted from any of the event streams in the given observable set. When an event stream is added to the set, the returned stream will start emitting its events. When an event stream is removed from the set, its events will no longer be emitted from the returned stream.
      • merge

        public static <T,​U> EventStream<U> merge​(javafx.collections.ObservableSet<? extends T> set,
                                                       java.util.function.Function<? super T,​? extends EventStream<U>> f)
        A more general version of merge(ObservableSet) for a set of arbitrary element type and a function to obtain an event stream from the element.
        Parameters:
        set - observable set of elements
        f - function to obtain an event stream from an element