Package org.reactfx
Class EventStreams
java.lang.Object
org.reactfx.EventStreams
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static final class
private static class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic EventStream
<Long> Returns a stream that, on each animation frame, emits the duration elapsed since the previous animation frame, in nanoseconds.static EventStream
<Long> Returns an event stream that emits a timestamp of the current frame in nanoseconds on every frame.static <T> EventStream
<Change<T>> changesOf
(javafx.beans.value.ObservableValue<T> observable) static <T> EventStream
<javafx.collections.ListChangeListener.Change<? extends T>> changesOf
(javafx.collections.ObservableList<T> list) static <K,
V> EventStream <javafx.collections.MapChangeListener.Change<? extends K, ? extends V>> changesOf
(javafx.collections.ObservableMap<K, V> map) static <T> EventStream
<javafx.collections.SetChangeListener.Change<? extends T>> changesOf
(javafx.collections.ObservableSet<T> set) static <A,
B> EventStream <Tuple2<A, B>> combine
(EventStream<A> srcA, EventStream<B> srcB) static <A,
B, C> EventStream <Tuple3<A, B, C>> combine
(EventStream<A> srcA, EventStream<B> srcB, EventStream<C> srcC) static <A,
B, C, D>
EventStream<Tuple4<A, B, C, D>> combine
(EventStream<A> srcA, EventStream<B> srcB, EventStream<C> srcC, EventStream<D> srcD) static <A,
B, C, D, E>
EventStream<Tuple5<A, B, C, D, E>> combine
(EventStream<A> srcA, EventStream<B> srcB, EventStream<C> srcC, EventStream<D> srcD, EventStream<E> srcE) static <A,
B, C, D, E, F>
EventStream<Tuple6<A, B, C, D, E, F>> combine
(EventStream<A> srcA, EventStream<B> srcB, EventStream<C> srcC, EventStream<D> srcD, EventStream<E> srcE, EventStream<F> srcF) private static <T> EventStream
<T> static <T extends javafx.event.Event>
EventStream<T> eventsOf
(javafx.scene.control.MenuItem menuItem, javafx.event.EventType<T> eventType) static <T extends javafx.event.Event>
EventStream<T> eventsOf
(javafx.scene.Node node, javafx.event.EventType<T> eventType) static <T extends javafx.event.Event>
EventStream<T> eventsOf
(javafx.scene.Scene scene, javafx.event.EventType<T> eventType) static <T extends javafx.event.Event>
EventStream<T> eventsOf
(javafx.stage.Window window, javafx.event.EventType<T> eventType) static <L,
R> Tuple2 <EventStream<L>, EventStream<R>> fork
(EventStream<? extends Either<L, R>> stream) static EventStream
<Void> invalidationsOf
(javafx.beans.Observable observable) Creates an event stream that emits an impulse on every invalidation of the given observable.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.static <T,
U> EventStream <U> merge
(javafx.collections.ObservableSet<? extends T> set, Function<? super T, ? extends EventStream<U>> f) A more general version ofmerge(ObservableSet)
for a set of arbitrary element type and a function to obtain an event stream from the element.static <T> EventStream
<T> merge
(EventStream<? extends T>... inputs) Returns an event stream that emits all the events emitted from any of theinputs
.static <T> EventStream
<T> never()
Returns an event stream that never emits any value.static <T> EventStream
<T> nonNullValuesOf
(javafx.beans.value.ObservableValue<T> observable) 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.static EventStream
<?> restartableTicks
(Duration interval, EventStream<?> impulse) Returns aticks(Duration)
EventStream whose timer restarts whenever impulse emits an event.static EventStream
<?> restartableTicks0
(Duration interval, EventStream<?> impulse) Returns aticks0(Duration)
EventStream whose timer restarts whenever impulse emits an event.static <T> EventStream
<ListModification<? extends T>> simpleChangesOf
(javafx.collections.ObservableList<T> list) Use only when the subscriber does not causelist
modification of the underlying list.static <C extends Collection<?> & javafx.beans.Observable>
EventStream<Integer> sizeOf
(C collection) static EventStream
<Integer> sizeOf
(javafx.collections.ObservableMap<?, ?> map) static EventStream
<?> Returns an event stream that emits periodic ticks.static EventStream
<?> ticks
(Duration interval, ScheduledExecutorService scheduler, Executor eventThreadExecutor) Returns an event stream that emits periodic ticks on the giveneventThreadExecutor
.static EventStream
<?> Returns an event stream that emits periodic ticks.static <T> EventStream
<T> valuesOf
(javafx.beans.value.ObservableValue<T> observable) Creates an event stream that emits the value of the givenObservableValue
immediately for every subscriber and then on every change.static <A,
B> EventStream <Tuple2<A, B>> zip
(EventStream<A> srcA, EventStream<B> srcB) static <A,
B, C> EventStream <Tuple3<A, B, C>> zip
(EventStream<A> srcA, EventStream<B> srcB, EventStream<C> srcC)
-
Field Details
-
NEVER
-
-
Constructor Details
-
EventStreams
public EventStreams()
-
-
Method Details
-
never
Returns an event stream that never emits any value. -
invalidationsOf
Creates an event stream that emits an impulse on every invalidation of the given observable. -
repeatOnInvalidation
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
Creates an event stream that emits the value of the givenObservableValue
immediately for every subscriber and then on every change. -
nonNullValuesOf
-
changesOf
public static <T> EventStream<Change<T>> changesOf(javafx.beans.value.ObservableValue<T> observable) -
changesOf
public static <T> EventStream<javafx.collections.ListChangeListener.Change<? extends T>> changesOf(javafx.collections.ObservableList<T> list) - See Also:
-
simpleChangesOf
public static <T> EventStream<ListModification<? extends T>> simpleChangesOf(javafx.collections.ObservableList<T> list) Use only when the subscriber does not causelist
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 Collection<?> & javafx.beans.Observable> EventStream<Integer> sizeOf(C collection) -
sizeOf
-
create
private static <T> EventStream<T> create(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
Returns an event stream that emits periodic ticks. The first tick is emitted afterinterval
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
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(Duration interval, ScheduledExecutorService scheduler, Executor eventThreadExecutor) Returns an event stream that emits periodic ticks on the giveneventThreadExecutor
. 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
Returns aticks(Duration)
EventStream whose timer restarts whenever impulse emits an event.- Parameters:
interval
- - the amount of time that passes until this stream emits its next tickimpulse
- - the EventStream that resets this EventStream's internal timer
-
restartableTicks0
Returns aticks0(Duration)
EventStream whose timer restarts whenever impulse emits an event. Note: sinceticks0(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 tickimpulse
- - the EventStream that resets this EventStream's internal timer
-
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 theAnimationTimer.handle(long)
method. -
animationFrames
Returns a stream that, on each animation frame, emits the duration elapsed since the previous animation frame, in nanoseconds. -
merge
Returns an event stream that emits all the events emitted from any of theinputs
. The event type of the returned stream is the nearest common super-type of all theinputs
.- See Also:
-
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, Function<? super T, ? extends EventStream<U>> f) A more general version ofmerge(ObservableSet)
for a set of arbitrary element type and a function to obtain an event stream from the element.- Parameters:
set
- observable set of elementsf
- function to obtain an event stream from an element
-
fork
public static <L,R> Tuple2<EventStream<L>,EventStream<R>> fork(EventStream<? extends Either<L, R>> stream) -
zip
-
zip
public static <A,B, EventStream<Tuple3<A,C> B, zipC>> (EventStream<A> srcA, EventStream<B> srcB, EventStream<C> srcC) -
combine
-
combine
public static <A,B, EventStream<Tuple3<A,C> B, combineC>> (EventStream<A> srcA, EventStream<B> srcB, EventStream<C> srcC) -
combine
public static <A,B, EventStream<Tuple4<A,C, D> B, combineC, D>> (EventStream<A> srcA, EventStream<B> srcB, EventStream<C> srcC, EventStream<D> srcD) -
combine
public static <A,B, EventStream<Tuple5<A,C, D, E> B, combineC, D, E>> (EventStream<A> srcA, EventStream<B> srcB, EventStream<C> srcC, EventStream<D> srcD, EventStream<E> srcE) -
combine
public static <A,B, EventStream<Tuple6<A,C, D, E, F> B, combineC, D, E, F>> (EventStream<A> srcA, EventStream<B> srcB, EventStream<C> srcC, EventStream<D> srcD, EventStream<E> srcE, EventStream<F> srcF)
-