T - type of values emitted by this stream.public interface EventStream<T> extends Observable<java.util.function.Consumer<? super T>>
| Modifier and Type | Method and Description |
|---|---|
default <U> EventStream<U> |
accumulate(java.util.function.BiFunction<? super U,? super T,? extends U> reduction,
java.util.function.Function<? super T,? extends U> initialTransformation)
Returns an event stream that accumulates events emitted from this event
stream and emits the accumulated value every time this stream emits a
value.
|
default EventStream<T> |
accumulate(java.util.function.BinaryOperator<T> reduction)
Returns an event stream that accumulates events emitted from this event
stream and emits the accumulated value every time this stream emits a
value.
|
default <U> EventStream<U> |
accumulate(U unit,
java.util.function.BiFunction<? super U,? super T,? extends U> reduction)
Returns an event stream that accumulates events emitted from this event
stream and emits the accumulated value every time this stream emits a
value.
|
default <A> EventStream<T> |
accumulateBetween(EventStream<?> ticks,
java.util.function.Function<? super T,? extends A> initialTransformation,
java.util.function.BiFunction<? super A,? super T,? extends A> accumulation,
java.util.function.Function<? super A,java.util.List<T>> deconstruction)
Returns an event stream that, when an event arrives from this stream,
transforms it into a cumulative value using the
initialTransformation function. |
default <A> EventStream<T> |
accumulateBetween(EventStream<?> ticks,
java.util.function.Supplier<? extends A> unit,
java.util.function.BiFunction<? super A,? super T,? extends A> accumulation,
java.util.function.Function<? super A,java.util.List<T>> deconstruction)
A variation on
accumulateBetween(EventStream, Function, BiFunction, Function)
to use when it is more convenient to provide a unit element of the
accumulation than to transform the initial event to a cumulative
value. |
default <A> EventStream<T> |
accumulateUntilLater(java.util.function.Function<? super T,? extends A> initialTransformation,
java.util.function.BiFunction<? super A,? super T,? extends A> accumulation,
java.util.function.Function<? super A,java.util.List<T>> deconstruction)
Returns an event stream that, when an event is emitted from this stream,
transforms the event to a cumulative value using the
initialTransformation function and schedules emission using
Platform.runLater(Runnable), if not already scheduled. |
default <A> EventStream<T> |
accumulateUntilLater(java.util.function.Function<? super T,? extends A> initialTransformation,
java.util.function.BiFunction<? super A,? super T,? extends A> accumulation,
java.util.function.Function<? super A,java.util.List<T>> deconstruction,
java.util.concurrent.Executor eventThreadExecutor)
Version of
accumulateUntilLater(Function, BiFunction, Function)
for event streams that don't live on the JavaFX application thread. |
default <A> EventStream<T> |
accumulateUntilLater(java.util.function.Supplier<? extends A> unit,
java.util.function.BiFunction<? super A,? super T,? extends A> accumulation,
java.util.function.Function<? super A,java.util.List<T>> deconstruction)
A variation on
accumulateUntilLater(Function, BiFunction, Function)
to use when it is more convenient to provide a unit element of the
accumulation than to transform the initial event to a cumulative
value. |
default <A> EventStream<T> |
accumulateUntilLater(java.util.function.Supplier<? extends A> unit,
java.util.function.BiFunction<? super A,? super T,? extends A> accumulation,
java.util.function.Function<? super A,java.util.List<T>> deconstruction,
java.util.concurrent.Executor eventThreadExecutor)
Version of
accumulateUntilLater(Supplier, BiFunction, Function)
for event streams that don't live on the JavaFX application thread. |
default <A> EventStream<T> |
accumulateWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition,
java.util.function.Function<? super T,? extends A> initialTransformation,
java.util.function.BiFunction<? super A,? super T,? extends A> accumulation,
java.util.function.Function<? super A,AccumulatorSize> size,
java.util.function.Function<? super A,? extends T> head,
java.util.function.Function<? super A,? extends A> tail)
Shortcut for
|
default <A> EventStream<T> |
accumulateWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition,
java.util.function.Supplier<? extends A> unit,
java.util.function.BiFunction<? super A,? super T,? extends A> accumulation,
java.util.function.Function<? super A,AccumulatorSize> size,
java.util.function.Function<? super A,? extends T> head,
java.util.function.Function<? super A,? extends A> tail)
Shortcut for
|
default <A> SuspendableEventStream<T> |
accumulative(java.util.function.Function<? super T,? extends A> initialTransformation,
java.util.function.BiFunction<? super A,? super T,? extends A> accumulation,
java.util.function.Function<? super A,AccumulatorSize> size,
java.util.function.Function<? super A,? extends T> head,
java.util.function.Function<? super A,? extends A> tail)
Returns a suspendable event stream that, when suspended, accumulates
incoming events to a cumulative value of type
A. |
default <A> SuspendableEventStream<T> |
accumulative(java.util.function.Supplier<? extends A> unit,
java.util.function.BiFunction<? super A,? super T,? extends A> accumulation,
java.util.function.Function<? super A,AccumulatorSize> size,
java.util.function.Function<? super A,? extends T> head,
java.util.function.Function<? super A,? extends A> tail)
A variation on
accumulative(Function, BiFunction, Function, Function, Function)
to use when it is more convenient to provide a unit element of the
accumulation than to transform the initial event to a cumulative
value. |
default <U extends T> |
cast(java.lang.Class<U> subtype)
Returns a new event stream that emits events emitted by this stream
cast to the given type.
|
default EventStream<T> |
conditionOn(javafx.beans.value.ObservableValue<java.lang.Boolean> condition)
|
default EventStream<T> |
conditionOnShowing(javafx.scene.Node node)
Equivalent to
conditionOn(ObservableValue) where the condition
is that node is showing: it is part of a scene graph
(Node.sceneProperty() is not null), its scene is part of
a window (Scene.windowProperty() is not null) and the
window is showing (Window.showingProperty() is true). |
default EventStream<T> |
distinct()
Returns a new event stream that emits repetitive events only once.
|
default <I> EventStream<Tuple2<T,I>> |
emitBothOnEach(EventStream<I> impulse)
Similar to
emitOnEach(EventStream), but also includes the
impulse in the emitted value. |
default EventStream<T> |
emitOn(EventStream<?> impulse)
Returns a new event stream that, when an event arrives from the
impulse stream, emits the most recent event emitted by this
stream. |
default EventStream<T> |
emitOnEach(EventStream<?> impulse)
Returns a new event stream that, when an event arrives from the
impulse stream, emits the most recent event emitted by this
stream. |
default Subscription |
feedTo(EventSink<? super T> sink)
Starts pushing all events emitted by this stream to the given event sink.
|
default Subscription |
feedTo(javafx.beans.value.WritableValue<? super T> dest)
Starts setting all events emitted by this stream as the value of the
given writable value.
|
default <U extends T> |
filter(java.lang.Class<U> subtype)
Filters this event stream by the runtime type of the values.
|
default EventStream<T> |
filter(java.util.function.Predicate<? super T> predicate)
Returns a new event stream that emits events emitted from this stream
that satisfy the given predicate.
|
default <U> EventStream<U> |
filterMap(java.util.function.Function<? super T,java.util.Optional<U>> f)
Equivalent to
|
default <U> EventStream<U> |
filterMap(java.util.function.Predicate<? super T> predicate,
java.util.function.Function<? super T,? extends U> f)
A more efficient equivalent to
filter(predicate).map(f). |
default <U> EventStream<U> |
flatMap(java.util.function.Function<? super T,? extends EventStream<U>> f)
Returns a new event stream that, for each event x emitted from
this stream, obtains the event stream f(x) and keeps emitting its
events until the next event is emitted from this stream.
|
default SuspendableEventStream<T> |
forgetful()
Returns a suspendable event stream that, when suspended, forgets all but
the latest event emitted by this event stream.
|
default Tuple2<EventStream<T>,EventStream<T>> |
fork(java.util.function.Predicate<? super T> test)
Returns two event streams, the first one emitting events of this stream
that satisfy the given
test and the second one emitting events
of this stream that do not satisfy the test. |
default EventStream<T> |
guardedBy(Guardian... guardians)
Deprecated.
Use
suspenderOf(Suspendable) instead. |
default EventStream<T> |
hook(java.util.function.Consumer<? super T> sideEffect)
Returns an event stream that emits the same(*) events as this
stream, but before emitting each event performs the given side
effect.
|
default EventStream<java.util.List<T>> |
latestN(int n)
Returns an event stream that emits lists of
n latest events
emitted from this stream. |
default <U> EventStream<U> |
map(java.util.function.Function<? super T,? extends U> f)
Returns a new event stream that applies the given function to every
value emitted from this stream and emits the result.
|
default <U> CompletionStageStream<U> |
mapToCompletionStage(java.util.function.Function<? super T,java.util.concurrent.CompletionStage<U>> f)
Similar to
map(Function), but the returned stream is a
CompletionStageStream, which can be used to await the results
of asynchronous computation. |
default <U> TaskStream<U> |
mapToTask(java.util.function.Function<? super T,javafx.concurrent.Task<U>> f)
Similar to
map(Function), but the returned stream is a
TaskStream, which can be used to await the results of
asynchronous computation. |
default <A> EventStream<T> |
onRecurseAccumulate(java.util.function.Function<? super T,? extends A> initialTransformation,
java.util.function.BiFunction<? super A,? super T,? extends A> reduction,
java.util.function.Function<? super A,AccumulatorSize> size,
java.util.function.Function<? super A,? extends T> head,
java.util.function.Function<? super A,? extends A> tail) |
default <A> EventStream<T> |
onRecurseAccumulate(java.util.function.Supplier<? extends A> unit,
java.util.function.BiFunction<? super A,? super T,? extends A> reduction,
java.util.function.Function<? super A,AccumulatorSize> size,
java.util.function.Function<? super A,? extends T> head,
java.util.function.Function<? super A,? extends A> tail) |
default EventStream<T> |
onRecurseQueue() |
default EventStream<T> |
onRecurseReduce(java.util.function.BinaryOperator<T> reduction) |
default EventStream<T> |
onRecurseRetainLatest() |
default <U> EventStream<Either<T,U>> |
or(EventStream<? extends U> right)
Returns an event stream that emits all the events emitted from either
this stream or the
right stream. |
default SuspendableEventStream<T> |
pausable()
Returns a suspendable event stream that, when suspended, stores the
events emitted by this event stream and emits them when the returned
stream's emission is resumed.
|
default EventStream<T> |
pauseWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition)
Shortcut for
pausable().suspendedWhen(condition). |
default Subscription |
pin()
If this stream is a compound stream lazily subscribed to its inputs,
that is, subscribed to inputs only when it itself has some subscribers,
pinning this stream causes it to stay subscribed until the
pinning is revoked by calling unsubscribe() on the returned
subscription. |
default EventStream<T> |
queueBetween(EventStream<?> ticks)
Returns an event stream that, when an event arrives from this stream,
enqueues it for emission.
|
default EventStream<T> |
queueUntilLater()
Returns an event stream that, when an event is emitted from this stream,
enqueues the event for emission and schedules emission using
Platform.runLater(Runnable), if not already scheduled. |
default EventStream<T> |
queueUntilLater(java.util.concurrent.Executor eventThreadExecutor)
Version of
queueUntilLater() for event streams that don't live
on the JavaFX application thread. |
default EventStream<T> |
reduceBetween(EventStream<?> ticks,
java.util.function.BinaryOperator<T> reduction)
Returns an event stream that, when an event arrives from this stream,
stores it for emission.
|
default AwaitingEventStream<T> |
reduceSuccessions(java.util.function.BinaryOperator<T> reduction,
java.time.Duration timeout)
Returns an event stream that accumulates events emitted from this event
stream in close temporal succession.
|
default AwaitingEventStream<T> |
reduceSuccessions(java.util.function.BinaryOperator<T> reduction,
java.time.Duration timeout,
java.util.concurrent.ScheduledExecutorService scheduler,
java.util.concurrent.Executor eventThreadExecutor)
An analog to
reduceSuccessions(BinaryOperator, Duration)
to use outside of JavaFX application thread. |
default <U> AwaitingEventStream<U> |
reduceSuccessions(java.util.function.Function<? super T,? extends U> initialTransformation,
java.util.function.BiFunction<? super U,? super T,? extends U> reduction,
java.time.Duration timeout)
A more general version of
reduceSuccessions(BinaryOperator, Duration)
that allows the accumulated event to be of different type. |
default <U> AwaitingEventStream<U> |
reduceSuccessions(java.util.function.Function<? super T,? extends U> initialTransformation,
java.util.function.BiFunction<? super U,? super T,? extends U> reduction,
java.time.Duration timeout,
java.util.concurrent.ScheduledExecutorService scheduler,
java.util.concurrent.Executor eventThreadExecutor)
An analog to
reduceSuccessions(Function, BiFunction, Duration)
to use outside of JavaFX application thread. |
default <U> AwaitingEventStream<U> |
reduceSuccessions(java.util.function.Supplier<? extends U> unitSupplier,
java.util.function.BiFunction<? super U,? super T,? extends U> reduction,
java.time.Duration timeout)
A convenient method that can be used when it is more convenient to
supply an identity of the type
U than to transform an event
of type T to an event of type U. |
default <U> AwaitingEventStream<U> |
reduceSuccessions(java.util.function.Supplier<? extends U> unitSupplier,
java.util.function.BiFunction<? super U,? super T,? extends U> reduction,
java.time.Duration timeout,
java.util.concurrent.ScheduledExecutorService scheduler,
java.util.concurrent.Executor eventThreadExecutor)
An analog to
reduceSuccessions(Supplier, BiFunction, Duration)
to use outside of JavaFX application thread. |
default EventStream<T> |
reduceUntilLater(java.util.function.BinaryOperator<T> reduction)
Returns an event stream that, when an event is emitted from this stream,
stores the event for emission and schedules emission using
Platform.runLater(Runnable), if not already scheduled. |
default EventStream<T> |
reduceUntilLater(java.util.function.BinaryOperator<T> reduction,
java.util.concurrent.Executor eventThreadExecutor)
Version of
reduceUntilLater(BinaryOperator) for event streams
that don't live on the JavaFX application thread. |
default EventStream<T> |
reduceWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition,
java.util.function.BinaryOperator<T> reduction)
Shortcut for
reducible(reduction).suspendedWhen(condition). |
default SuspendableEventStream<T> |
reducible(java.util.function.BinaryOperator<T> reduction)
Returns a suspendable event stream that, when suspended, reduces incoming
events by the given
reduction function into one. |
default EventStream<T> |
repeatOn(EventStream<?> impulse)
Returns a new event stream that emits all the events emitted from this
stream and in addition to that re-emits the most recent event on every
event emitted from
impulse. |
default EventStream<T> |
retainLatestBetween(EventStream<?> ticks)
Equivalent to
emitOn(EventStream). |
default EventStream<T> |
retainLatestUntilLater()
Returns an event stream that, when an event is emitted from this stream,
stores the event for emission and schedules emission using
Platform.runLater(Runnable), if not already scheduled. |
default EventStream<T> |
retainLatestUntilLater(java.util.concurrent.Executor eventThreadExecutor)
Version of
retainLatestUntilLater() for event streams that
don't live on the JavaFX application thread. |
default EventStream<T> |
retainLatestWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition)
Shortcut for
forgetful().suspendedWhen(condition). |
default EventStream<Either<T,T>> |
splitBy(java.util.function.Predicate<? super T> test)
Returns a new event stream that, for event
e emitted from this
stream, emits left(e) if e passes the given test, and
emits right(e) if e does not pass the test. |
default Subscription |
subscribe(java.util.function.Consumer<? super T> subscriber)
Get notified every time this event stream emits a value.
|
default Subscription |
subscribeFor(int n,
java.util.function.Consumer<? super T> subscriber)
Subscribes to this event stream for at most
n events. |
default Subscription |
subscribeForOne(java.util.function.Consumer<? super T> subscriber)
Shorthand for
subscribeFor(1, subscriber). |
default AwaitingEventStream<T> |
successionEnds(java.time.Duration timeout)
Returns an event stream that, when events are emitted from this stream
in close temporal succession, emits only the last event of the
succession.
|
default AwaitingEventStream<T> |
successionEnds(java.time.Duration timeout,
java.util.concurrent.ScheduledExecutorService scheduler,
java.util.concurrent.Executor eventThreadExecutor)
An analog to
successionEnds(Duration) to use outside of JavaFX
application thread. |
default <U> EventStream<U> |
supply(java.util.function.Supplier<? extends U> f)
Returns an event stream that emits a value obtained from the given
supplier every time this event stream emits a value.
|
default <U> EventStream<U> |
supply(U value)
Returns an event stream that emits the given constant value every time
this stream emits a value.
|
default <U> CompletionStageStream<U> |
supplyCompletionStage(java.util.function.Supplier<java.util.concurrent.CompletionStage<U>> f)
Similar to
supply(Supplier), but the returned stream is a
CompletionStageStream, which can be used to await the results
of asynchronous computation. |
default <U> TaskStream<U> |
supplyTask(java.util.function.Supplier<javafx.concurrent.Task<U>> f)
Similar to
supply(Supplier), but the returned stream is a
CompletionStageStream, which can be used to await the results
of asynchronous computation. |
default SuspendableEventStream<T> |
suppressible()
Returns a suspendable event stream that, when suspended, suppresses
any events emitted by this event stream.
|
default EventStream<T> |
suppressWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition)
Shortcut for
suppressible().suspendedWhen(condition). |
default <S extends Suspendable> |
suspenderOf(S suspendable)
Returns an event stream that emits the same events as this event stream,
but before each emission, suspends the given Suspendable
and unsuspends it after the emission has completed.
|
default <A> AwaitingEventStream<T> |
thenAccumulateFor(java.time.Duration duration,
java.util.function.Function<? super T,? extends A> initialTransformation,
java.util.function.BiFunction<? super A,? super T,? extends A> reduction,
java.util.function.Function<? super A,java.util.List<T>> deconstruction)
Returns an event stream that emits the first event emitted from this
stream and then, if the next event arrives within the given duration
since the last emitted event, it is converted to an accumulator value
using
initialTransformation. |
default <A> AwaitingEventStream<T> |
thenAccumulateFor(java.time.Duration duration,
java.util.function.Function<? super T,? extends A> initialTransformation,
java.util.function.BiFunction<? super A,? super T,? extends A> reduction,
java.util.function.Function<? super A,java.util.List<T>> deconstruction,
java.util.concurrent.ScheduledExecutorService scheduler,
java.util.concurrent.Executor eventThreadExecutor) |
default <A> AwaitingEventStream<T> |
thenAccumulateFor(java.time.Duration duration,
java.util.function.Supplier<? extends A> unit,
java.util.function.BiFunction<? super A,? super T,? extends A> reduction,
java.util.function.Function<? super A,java.util.List<T>> deconstruction)
A variant of
thenAccumulateFor(Duration, Function, BiFunction, Function)
for cases when it is more convenient to provide a unit element for
accumulation than the initial transformation. |
default <A> AwaitingEventStream<T> |
thenAccumulateFor(java.time.Duration duration,
java.util.function.Supplier<? extends A> unit,
java.util.function.BiFunction<? super A,? super T,? extends A> reduction,
java.util.function.Function<? super A,java.util.List<T>> deconstruction,
java.util.concurrent.ScheduledExecutorService scheduler,
java.util.concurrent.Executor eventThreadExecutor) |
default AwaitingEventStream<T> |
thenIgnoreFor(java.time.Duration duration)
Returns an event stream that emits the first event emitted from this
stream and then ignores the following events for the given duration.
|
default AwaitingEventStream<T> |
thenIgnoreFor(java.time.Duration duration,
java.util.concurrent.ScheduledExecutorService scheduler,
java.util.concurrent.Executor eventThreadExecutor) |
default AwaitingEventStream<T> |
thenReduceFor(java.time.Duration duration,
java.util.function.BinaryOperator<T> reduction)
Returns an event stream that emits the first event emitted from this
stream and then reduces all following events that arrive within the
given duration into a single event using the given reduction function.
|
default AwaitingEventStream<T> |
thenReduceFor(java.time.Duration duration,
java.util.function.BinaryOperator<T> reduction,
java.util.concurrent.ScheduledExecutorService scheduler,
java.util.concurrent.Executor eventThreadExecutor) |
default AwaitingEventStream<T> |
thenRetainLatestFor(java.time.Duration duration)
Returns an event stream that emits the first event emitted from this
stream and then remembers, but does not emit, the latest event emitted
from this stream.
|
default AwaitingEventStream<T> |
thenRetainLatestFor(java.time.Duration duration,
java.util.concurrent.ScheduledExecutorService scheduler,
java.util.concurrent.Executor eventThreadExecutor) |
default EventStream<T> |
threadBridge(java.util.concurrent.Executor sourceThreadExecutor,
java.util.concurrent.Executor targetThreadExecutor)
Transfers events from one thread to another.
|
default EventStream<T> |
threadBridgeFromFx(java.util.concurrent.Executor targetThreadExecutor)
Transfers events from the JavaFX application thread to another thread.
|
default EventStream<T> |
threadBridgeToFx(java.util.concurrent.Executor sourceThreadExecutor)
Transfers events to the JavaFX application thread.
|
default javafx.beans.binding.Binding<T> |
toBinding(T initialValue)
Returns a binding that holds the most recent event emitted from this
stream.
|
default EventStream<T> |
withDefaultEvent(T defaultEvent)
Returns an event stream that immediately emits its event when something
subscribes to it.
|
addObserver, observe, removeObserverdefault Subscription subscribe(java.util.function.Consumer<? super T> subscriber)
subscriber - handles emitted events.default Subscription subscribeFor(int n, java.util.function.Consumer<? super T> subscriber)
n events.
The subscriber is automatically removed after handling n events.n - limit on how many events may be handled by subscriber.
Must be positive.subscriber - handles emitted events.n events handled by subscriber.default Subscription subscribeForOne(java.util.function.Consumer<? super T> subscriber)
subscribeFor(1, subscriber).default Subscription feedTo(EventSink<? super T> sink)
stream.feedTo(sink) is equivalent to
sink.feedFrom(stream)
sink - event sink to which this event stream's events will be pushedsink.EventSink.feedFrom(EventStream)default Subscription feedTo(javafx.beans.value.WritableValue<? super T> dest)
subscribe(dest::setValue).default Subscription pin()
pinning this stream causes it to stay subscribed until the
pinning is revoked by calling unsubscribe() on the returned
subscription.
Equivalent to subscribe(x -> {}).
default EventStream<T> withDefaultEvent(T defaultEvent)
EventStream<Boolean> controlPresses = EventStreams
.eventsOf(scene, KeyEvent.KEY_PRESSED)
.filter(key -> key.getCode().is(KeyCode.CONTROL))
.map(key -> key.isControlDown());
EventSource<?> other;
EventStream<Tuple2<Boolean, ?>> combo = EventStreams.combine(controlPresses, other);
// This will not run until user presses the control key at least once.
combo.subscribe(tuple2 -> System.out.println("Combo emitted an event."));
EventStream<Boolean> controlDown = controlPresses.withDefaultEvent(false);
EventStream<Tuple2<Boolean, ?>> betterCombo = EventStreams.combine(controlDown, other);
betterCombo.subscribe(tuple2 -> System.out.println("Better Combo emitted an event immediately upon program start."));
defaultEvent - the event this event stream will emit if something subscribes to this stream and this stream does not have an event.default EventStream<T> hook(java.util.function.Consumer<? super T> sideEffect)
(*) The returned stream is lazily bound, so it only emits events and performs side effects when it has at least one subscriber.
default EventStream<T> filter(java.util.function.Predicate<? super T> predicate)
default <U extends T> EventStream<U> filter(java.lang.Class<U> subtype)
filter(SomeClass.class) is equivalent to
filter(x -> x instanceof SomeClass).map(x -> (SomeClass) x).default EventStream<T> distinct()
EventStream<Integer> A = ...;
EventStream<Integer> B = A.distinct();
Returns B. When A emits an event, B only emits that event if it's different from the previous event emitted by A.
Time --->
A :-3--3---3-4---4---4---5-4-5--5--5->
B :-3--------4-----------5-4-5------->
default <U> EventStream<U> supply(U value)
EventStream<Integer> A = ...;
EventStream<Integer> B = A.supply(5);
Returns B. When A emits an event, B emits the supplied value.
Time --->
A :-3--0--6--4-1--1---5-4-5--8--2->
B :-5--5--5--5-5--5---5-5-5--5--5->
default <U> EventStream<U> supply(java.util.function.Supplier<? extends U> f)
EventStream<?> A = ...;
SimpleIntegerProperty intProp = ...;
EventStream<Double> B = A.supply(intProp::get);
Returns B. When A emits an event, B emits the supplier's value.
Time --->
A :----a----b------c----d----e---->
intProp :-3--------6---------9---------->
B :----3----3------6----9----9---->
default <U> CompletionStageStream<U> supplyCompletionStage(java.util.function.Supplier<java.util.concurrent.CompletionStage<U>> f)
supply(Supplier), but the returned stream is a
CompletionStageStream, which can be used to await the results
of asynchronous computation.default <U> TaskStream<U> supplyTask(java.util.function.Supplier<javafx.concurrent.Task<U>> f)
supply(Supplier), but the returned stream is a
CompletionStageStream, which can be used to await the results
of asynchronous computation.default <U> EventStream<U> map(java.util.function.Function<? super T,? extends U> f)
EventStream<Integer> A = ...;
EventStream<Integer> B = A.map(intValue -> intValue * 2);
Returns B. When A emits an event, the event is mapped by the function (in this case, it multiples A's emitted value by two) and B emits this mapped event.
Time --->
A :-3---1--4--5--2--0---3--7--->
B :-6---2--8--10-4--0---6--14-->
default <U extends T> EventStream<U> cast(java.lang.Class<U> subtype)
cast(SomeClass.class) is equivalent to
map(x -> (SomeClass) x).default EventStream<Either<T,T>> splitBy(java.util.function.Predicate<? super T> test)
e emitted from this
stream, emits left(e) if e passes the given test, and
emits right(e) if e does not pass the test.default Tuple2<EventStream<T>,EventStream<T>> fork(java.util.function.Predicate<? super T> test)
test and the second one emitting events
of this stream that do not satisfy the test.default <U> CompletionStageStream<U> mapToCompletionStage(java.util.function.Function<? super T,java.util.concurrent.CompletionStage<U>> f)
map(Function), but the returned stream is a
CompletionStageStream, which can be used to await the results
of asynchronous computation.default <U> TaskStream<U> mapToTask(java.util.function.Function<? super T,javafx.concurrent.Task<U>> f)
map(Function), but the returned stream is a
TaskStream, which can be used to await the results of
asynchronous computation.default <U> EventStream<U> filterMap(java.util.function.Predicate<? super T> predicate, java.util.function.Function<? super T,? extends U> f)
filter(predicate).map(f).default <U> EventStream<U> filterMap(java.util.function.Function<? super T,java.util.Optional<U>> f)
map(f)
.filter(Optional::isPresent)
.map(Optional::get)
with more efficient implementation.default <U> EventStream<U> flatMap(java.util.function.Function<? super T,? extends EventStream<U>> f)
EventStream<Integer> A = ...;
EventStream<Integer> B = ...;
EventStream<Integer> C = ...;
EventStream<Integer> D = A.flatMap(intValue -> {
intValue < 4
? B
: C
})
Returns D. When A emits an event that is less than 4, D will emit B's events. Otherwise, D will emit C's events. When A emits a new event, the stream whose events D will emit is re-determined.
Time --->
A :-3---1--4--5--2--0---3--5--------->
B :--4-7---8--7----4-----34---5--56-->
C :----6---6----5---8----9---2---5--->
Stream :-BBBBBBBCCCCCCBBBBBBBBBBCCCCCCCCC->
D :--4-7---6----5--4-----34--2---5--->
default EventStream<T> conditionOn(javafx.beans.value.ObservableValue<java.lang.Boolean> condition)
condition is true.
More precisely, the returned EventStream observes
condition whenever it itself has at least one subscriber and
observes this EventStream whenever it itself has
at least one subscriber and the value of condition is
true. When condition is true, the returned
EventStream emits the same events as this
EventStream. When condition is false, the
returned EventStream emits no events.default EventStream<T> conditionOnShowing(javafx.scene.Node node)
conditionOn(ObservableValue) where the condition
is that node is showing: it is part of a scene graph
(Node.sceneProperty() is not null), its scene is part of
a window (Scene.windowProperty() is not null) and the
window is showing (Window.showingProperty() is true).default <U> EventStream<Either<T,U>> or(EventStream<? extends U> right)
right stream. An event t emitted from
this stream is emitted as Either.left(t). An event u
emitted from the right stream is emitted as
Either.right(u).EventStreams.merge(EventStream...)default EventStream<java.util.List<T>> latestN(int n)
n latest events
emitted from this stream.
For example, given
EventStream<Integer> stream = ...;
EventStream<List<Integer>> latest3 = stream.latestN(3);
Time --->
stream :--1--2-----3--4--5-----6--->
latest3 :--a--b-----c--d--e-----f--->
then lastest3's values are
default EventStream<T> emitOn(EventStream<?> impulse)
impulse stream, emits the most recent event emitted by this
stream. Each event is emitted at most once.
For example,
EventStream<?> A = ...;
EventStream<?> B = ...;
EventStream<?> C = A.emitOn(B);
Returns C. When B emits an event, C emits A's most recent event. No, does not emit the most recent event multiple times.
Time --->
A :-a-------b-----c----------d------->
B :----i------------i--i--i-----i---->
C :----a------------c-----------d---->
emitOnEach(EventStream) does.
emitBothOnEach(EventStream)
emits both A and B's events as an event (a Tuple2)
repeatOn(EventStream) does.
default EventStream<T> emitOnEach(EventStream<?> impulse)
impulse stream, emits the most recent event emitted by this
stream. The same event may be emitted more than once.
For example,
EventStream<?> A = ...;
EventStream<?> B = ...;
EventStream<?> C = A.emitOnEach(B);
Returns C. When B emits an event, C emits A's most recent event. Yes, does emit the most recent event multiple times.
Time --->
A :-a-------b-----c----------d------->
B :----i------------i--i--i-----i---->
C :----a------------c--c--c-----d---->
emitOn(EventStream) does not.
emitBothOnEach(EventStream)
emits both A and B's events as an event.
repeatOn(EventStream) does.
default <I> EventStream<Tuple2<T,I>> emitBothOnEach(EventStream<I> impulse)
emitOnEach(EventStream), but also includes the
impulse in the emitted value.
For example,
EventStream<?> A = ...;
EventStream<?> B = ...;
EventStream<?> C = A.emitBothOnEach(B);
Returns C. When B emits an event, C emits A and B's most recent events.. Only emits an event when both A and B have emitted at least one new event.
Time --->
A :-a-------b---c------------------d------->
B :----1-----------2-----3-----4----------->
C :---[a,1]------[c,2]-----------[d,4]----->
emitOn(EventStream),
emitOnEach(EventStream), and repeatOn(EventStream)
only emit A's event under specific circumstances.
default EventStream<T> repeatOn(EventStream<?> impulse)
impulse.
For example,
EventStream<?> A = ...;
EventStream<?> B = ...;
EventStream<?> C = A.repeatOn(B);
Returns C. When A emits an event, C also emits that event. When B emits an event, C emits that most recent event that A emitted.
Time --->
A :-a-------b---c------------------d------->
B :----i-----------i-----i-----i----------->
C :-a--a----b---c--c-----c-----c---d------->
emitOn(EventStream) doesn't.
emitOnEach(EventStream) doesn't.
emitBothOnEach(EventStream)
emits both A and B's events as an event.
default SuspendableEventStream<T> suppressible()
default EventStream<T> suppressWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition)
suppressible().suspendedWhen(condition).default SuspendableEventStream<T> pausable()
EventStream<?> A = ...;
EventStream<?> B = A.pausable();
Returns B. When A emits an event and B is not suspended, B also emits that event. When B is suspended and A emits events, those events are stored in B. Once B is unsuspended, B emits those events.
Time --->
A :-a--b----c---d-----e------------f------->
B :-a--b--|---Suspended----|cde----f------->
default EventStream<T> pauseWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition)
pausable().suspendedWhen(condition).default SuspendableEventStream<T> forgetful()
EventStream<?> A = ...;
EventStream<?> B = A.forgetful();
Returns B. When B is not suspended and A emits an event, B emits that event. When B is suspended and A emits an event, B does not emit that event, nor does it store that event for later emission. Those events are "forgotten."
Time --->
A :-a--b----c---d-----e------------f------->
B :-a--b--|---Suspended----|-------f------->
default EventStream<T> retainLatestWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition)
forgetful().suspendedWhen(condition).default SuspendableEventStream<T> reducible(java.util.function.BinaryOperator<T> reduction)
reduction function into one. The reduced
event is emitted from the returned stream upon resume.
For example,
EventStream<Integer> A = ...;
EventStream<Integer> B = A.reducible(lastStored_A_Event, mostRecent_A_EventEmitted -> {
lastStored_A_Event <= 4
? mostRecent_A_EventEmitted
: lastStored_A_Event;
});
Returns B. When B is not suspended and A emits an event, B emits that event.
When B is suspended and A emits events (En) where n is the number of the event,
B applies reduction(En-1, En). When B is no longer suspended, it emits result
Time --->
A :-1--2----4--1--5-----7------------6------->
B :-1--2--|---Suspended---|5---------6------->
result :-------|-a--b--c-----d-|------------------>
then result's values are:
Note that forgetful() is equivalent to
reducible((a, b) -> b).
default EventStream<T> reduceWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition, java.util.function.BinaryOperator<T> reduction)
reducible(reduction).suspendedWhen(condition).default <A> SuspendableEventStream<T> accumulative(java.util.function.Function<? super T,? extends A> initialTransformation, java.util.function.BiFunction<? super A,? super T,? extends A> accumulation, java.util.function.Function<? super A,AccumulatorSize> size, java.util.function.Function<? super A,? extends T> head, java.util.function.Function<? super A,? extends A> tail)
A. When the
returned stream is resumed, the accumulated value is deconstructed into
a sequence of events that are emitted from the returned stream.
Note that suppressible() is equivalent to
accumulative(
t -> (Void) null, // use null as accumulator
(a, t) -> a, // keep null as accumulator
a -> AccumulatorSize.ZERO, // no events to be emitted from accumulator
a -> throw new NoSuchElementException(), // head is never called on empty accumulator
a -> throw new NoSuchElementException()) // tail is never called on empty accumulator
Note that reducible(reduction) is equivalent to
accumulative(
t -> t, // the event itself is the accumulator
reduction,
t -> AccumulatorSize.ONE, // one event to be emitted
t -> t, // head of a single value is the value itself
t -> throw new NoSuchElementException) // tail is never called on accumulator of size one
A - type of the cumulative valueinitialTransformation - Used to convert the first event after
suspension to the cumulative value.accumulation - Used to accumulate further incoming events to the
cumulative value.size - determines how many events can be emitted from the current
cumulative value.head - produces the first event off the cumulative value.tail - returns a cumulative value that produces the same events
as the given cumulative value, except the event returned by head.
May be destructive for the given cumulative value.default <A> EventStream<T> accumulateWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition, java.util.function.Function<? super T,? extends A> initialTransformation, java.util.function.BiFunction<? super A,? super T,? extends A> accumulation, java.util.function.Function<? super A,AccumulatorSize> size, java.util.function.Function<? super A,? extends T> head, java.util.function.Function<? super A,? extends A> tail)
accumulative(initialTransformation, accumulation, size, head, tail)
.suspendedWhen(condition)
default <A> SuspendableEventStream<T> accumulative(java.util.function.Supplier<? extends A> unit, java.util.function.BiFunction<? super A,? super T,? extends A> accumulation, java.util.function.Function<? super A,AccumulatorSize> size, java.util.function.Function<? super A,? extends T> head, java.util.function.Function<? super A,? extends A> tail)
accumulative(Function, BiFunction, Function, Function, Function)
to use when it is more convenient to provide a unit element of the
accumulation than to transform the initial event to a cumulative
value. It is equivalent to
accumulative(t -> accumulation.apply(unit.get(), t), accumulation, size, head, tail),
i.e. the initial transformation is achieved by accumulating the initial
event to the unit element.
Note that pausable() is equivalent to
accumulative(
LinkedList<T>::new, // the unit element is an empty queue
(q, t) -> { q.addLast(t); return q; }, // accumulation is addition to the queue
q -> AccumulatorSize.fromInt(q.size()), // size is the size of the queue
Deque::getFirst, // head is the first element of the queue
q -> { q.removeFirst(); return q; }) // tail removes the first element from the queue
A - type of the cumulative valueunit - Function that supplies unit element of the accumulation.accumulation - Used to accumulate further incoming events to the
cumulative value.size - determines how many events can be emitted from the current
cumulative value.head - produces the first event off the cumulative value.tail - returns a cumulative value that produces the same events
as the given cumulative value, except the event returned by head.
May be destructive for the given cumulative value.default <A> EventStream<T> accumulateWhen(javafx.beans.value.ObservableValue<java.lang.Boolean> condition, java.util.function.Supplier<? extends A> unit, java.util.function.BiFunction<? super A,? super T,? extends A> accumulation, java.util.function.Function<? super A,AccumulatorSize> size, java.util.function.Function<? super A,? extends T> head, java.util.function.Function<? super A,? extends A> tail)
accumulative(unit, accumulation, size, head, tail)
.suspendedWhen(condition)
default <A> EventStream<T> accumulateBetween(EventStream<?> ticks, java.util.function.Function<? super T,? extends A> initialTransformation, java.util.function.BiFunction<? super A,? super T,? extends A> accumulation, java.util.function.Function<? super A,java.util.List<T>> deconstruction)
initialTransformation function. Any further events that arrive
from this stream are accumulated to the cumulative value using the
accumulation function. When an event arrives from the
ticks stream, the accumulated value is deconstructed into a
sequence of events using the deconstruction function and the
events are emitted from the returned stream.
Note that reduceBetween(ticks, reduction) is equivalent to
accumulateBetween(ticks, t -> t, reduction, Collections::singletonList).
default <A> EventStream<T> accumulateBetween(EventStream<?> ticks, java.util.function.Supplier<? extends A> unit, java.util.function.BiFunction<? super A,? super T,? extends A> accumulation, java.util.function.Function<? super A,java.util.List<T>> deconstruction)
accumulateBetween(EventStream, Function, BiFunction, Function)
to use when it is more convenient to provide a unit element of the
accumulation than to transform the initial event to a cumulative
value. It is equivalent to
accumulateBetween(ticks, t -> accumulation.apply(unit.get(), t), accumulation, deconstruction),
i.e. the initial transformation is achieved by accumulating the initial
event to the unit element.
Note that queueBetween(ticks) is equivalent to
accumulateBetween(ticks, ArrayList<T>::new, (l, t) -> { l.add(t); return l; }, l -> l),
i.e. the unit element is an empty list, accumulation is addition to the
list and deconstruction of the accumulated value is a no-op, since the
accumulated value is already a list of events.
default EventStream<T> reduceBetween(EventStream<?> ticks, java.util.function.BinaryOperator<T> reduction)
reduction function.
The stored event is emitted from the returned stream when a tick
arrives from the ticks stream.
Note that retainLatestBetween(ticks) is equivalent to
reduceBetween(ticks, (a, b) -> b).
default EventStream<T> queueBetween(EventStream<?> ticks)
ticks stream.default EventStream<T> retainLatestBetween(EventStream<?> ticks)
emitOn(EventStream).default <A> EventStream<T> accumulateUntilLater(java.util.function.Function<? super T,? extends A> initialTransformation, java.util.function.BiFunction<? super A,? super T,? extends A> accumulation, java.util.function.Function<? super A,java.util.List<T>> deconstruction, java.util.concurrent.Executor eventThreadExecutor)
accumulateUntilLater(Function, BiFunction, Function)
for event streams that don't live on the JavaFX application thread.eventThreadExecutor - executor that executes actions on the thread
from which this event stream is accessed.default <A> EventStream<T> accumulateUntilLater(java.util.function.Function<? super T,? extends A> initialTransformation, java.util.function.BiFunction<? super A,? super T,? extends A> accumulation, java.util.function.Function<? super A,java.util.List<T>> deconstruction)
initialTransformation function and schedules emission using
Platform.runLater(Runnable), if not already scheduled. Any new
event that arrives from this stream before the scheduled emission is
executed is accumulated to the stored cumulative value using the given
accumulation function. When the scheduled emission is finally
executed, the accumulated value is deconstructed into a sequence of
events using the deconstruction function and the events are
emitted from the returned stream.
Note that reduceUntilLater(reduction) is equivalent to
accumulateUntilLater(t -> t, reduction, t -> Collections::singletonList).
A - type of the cumulative value (accumulator)default <A> EventStream<T> accumulateUntilLater(java.util.function.Supplier<? extends A> unit, java.util.function.BiFunction<? super A,? super T,? extends A> accumulation, java.util.function.Function<? super A,java.util.List<T>> deconstruction, java.util.concurrent.Executor eventThreadExecutor)
accumulateUntilLater(Supplier, BiFunction, Function)
for event streams that don't live on the JavaFX application thread.eventThreadExecutor - executor that executes actions on the thread
from which this event stream is accessed.default <A> EventStream<T> accumulateUntilLater(java.util.function.Supplier<? extends A> unit, java.util.function.BiFunction<? super A,? super T,? extends A> accumulation, java.util.function.Function<? super A,java.util.List<T>> deconstruction)
accumulateUntilLater(Function, BiFunction, Function)
to use when it is more convenient to provide a unit element of the
accumulation than to transform the initial event to a cumulative
value. It is equivalent to
accumulateUntilLater(t -> accumulation.apply(unit.get(), t), accumulation, deconstruction),
i.e. the initial transformation is achieved by accumulating the initial
event to the unit element.
Note that queueUntilLater() is equivalent to
accumulateUntilLater(ArrayList<T>::new, (l, t) -> { l.add(t); return l; }, l -> l),
i.e. the unit element is an empty list, accumulation is addition to the
list and deconstruction of the accumulated value is a no-op, since the
accumulated value is already a list of events.
A - type of the cumulative value (accumulator)default EventStream<T> reduceUntilLater(java.util.function.BinaryOperator<T> reduction, java.util.concurrent.Executor eventThreadExecutor)
reduceUntilLater(BinaryOperator) for event streams
that don't live on the JavaFX application thread.eventThreadExecutor - executor that executes actions on the thread
from which this event stream is accessed.default EventStream<T> reduceUntilLater(java.util.function.BinaryOperator<T> reduction)
Platform.runLater(Runnable), if not already scheduled. Any new
event that arrives from this stream before the scheduled emission is
executed is accumulated into the stored event using the given
reduction function. When the scheduled emission is finally
executed, the stored event is emitted from the returned stream.
Note that retainLatestUntilLater() is equivalent to
reduceUntilLater((a, b) -> b).
default EventStream<T> retainLatestUntilLater(java.util.concurrent.Executor eventThreadExecutor)
retainLatestUntilLater() for event streams that
don't live on the JavaFX application thread.eventThreadExecutor - executor that executes actions on the thread
from which this event stream is accessed.default EventStream<T> retainLatestUntilLater()
Platform.runLater(Runnable), if not already scheduled. If a new
event arrives from this stream before the scheduled emission is executed,
the stored event is overwritten by the new event and only the new event is
emitted when the scheduled emission is finally executed.default EventStream<T> queueUntilLater(java.util.concurrent.Executor eventThreadExecutor)
queueUntilLater() for event streams that don't live
on the JavaFX application thread.eventThreadExecutor - executor that executes actions on the thread
from which this event stream is accessed.default EventStream<T> queueUntilLater()
Platform.runLater(Runnable), if not already scheduled. Any events
that arrive from this stream before a scheduled emission is executed are
enqueued as well and emitted (in order) when the scheduled emission is
finally executed.default javafx.beans.binding.Binding<T> toBinding(T initialValue)
dispose() method is called.initialValue - used as the returned binding's value until this
stream emits the first value.default EventStream<T> accumulate(java.util.function.BinaryOperator<T> reduction)
reduction - function to reduce two events into one.default <U> EventStream<U> accumulate(U unit, java.util.function.BiFunction<? super U,? super T,? extends U> reduction)
EventStream<String> A = ...;
EventStream<String> B = A.accumulate(
// Unit
"Cheese",
// reduction
(lastStored_A_Event, mostRecent_A_EventEmitted) -> {
lastStored_A_Event.length() > mostRecent_A_EventEmitted
? lastStored_A_Event.subString(0, mostRecent_A_EventEmitted.length())
: mostRecent_A_EventEmitted
}
);
Returns B. When A emits an event, B emits the result of
applying the reduction function on those events. When A emits its first
event, B supplies Unit as the 'lastStored_A_Event'.
Time --->
A :-"Cake"--"Sugar"--"Oil"--"French Toast"---"Cookie"----->
B :--1---------2--------3------4--------------5------------>
where "#" is:
unit - initial value of the accumulated value.reduction - function to add an event to the accumulated value.default <U> EventStream<U> accumulate(java.util.function.BiFunction<? super U,? super T,? extends U> reduction, java.util.function.Function<? super T,? extends U> initialTransformation)
// assumes that A only emits String events that are 1 char long.
EventStream<String> A = ...;
EventStream<String> B = A.accumulate(
// reduction
(lastStored_A_Event, mostRecent_A_EventEmitted) -> {
mostRecent_A_EventEmitted.isVowel()
? lastStored_A_Event + mostRecent_A_EventEmitted
: mostRecent_A_EventEmitted
},
// initial transformation
first_A_EvenEmitted ->
first_A_EventEmitted.isConsonant()
? first_A_EventEmitted
: "M"
);
Returns B. The first time A emits an event, B emits the result of
applying the initial transformation function to that event. For every
event emitted after that, B emits the result of applying the reduction
function on those events.
Time --->
A :-D--O---E---L---K---I--U---T----->
B :-1--2---3---4---5---6--7---8----->
where "#" is:
reduction - function to add an event to the accumulated value.initialTransformation - function to transform the first event from
this stream to an event that can be emitted from the returned stream.
Subsequent events emitted from this stream are accumulated to the value
returned from this function.default AwaitingEventStream<T> reduceSuccessions(java.util.function.BinaryOperator<T> reduction, java.time.Duration timeout)
timeout for the next
event from this stream. If the next event arrives within timeout, it is
accumulated to the current event by the reduction function and
the timeout is reset. When the timeout expires, the accumulated event is
emitted from the returned stream.
Note: This function can be used only when this stream and
the returned stream are used from the JavaFX application thread. If
you are using the event streams on a different thread, use
reduceSuccessions(BinaryOperator, Duration, ScheduledExecutorService, Executor)
instead.
reduction - function to reduce two events into one.timeout - the maximum time difference between two subsequent
events that can still be accumulated.default <U> AwaitingEventStream<U> reduceSuccessions(java.util.function.Function<? super T,? extends U> initialTransformation, java.util.function.BiFunction<? super U,? super T,? extends U> reduction, java.time.Duration timeout)
reduceSuccessions(BinaryOperator, Duration)
that allows the accumulated event to be of different type.
Note: This function can be used only when this stream and
the returned stream are used from the JavaFX application thread. If
you are using the event streams on a different thread, use
reduceSuccessions(Function, BiFunction, Duration, ScheduledExecutorService, Executor)
instead.
U - type of events emitted from the returned stream.initialTransformation - function to transform a single event
from this stream to an event that can be emitted from the returned
stream.reduction - function to add an event to the accumulated value.timeout - the maximum time difference between two subsequent
events that can still be accumulated.default <U> AwaitingEventStream<U> reduceSuccessions(java.util.function.Supplier<? extends U> unitSupplier, java.util.function.BiFunction<? super U,? super T,? extends U> reduction, java.time.Duration timeout)
U than to transform an event
of type T to an event of type U.
This method is equivalent to
reduceSuccessions(t -> reduction.apply(identitySupplier.get(), t), reduction, timeout).
Note: This function can be used only when this stream and
the returned stream are used from the JavaFX application thread. If
you are using the event streams on a different thread, use
reduceSuccessions(Supplier, BiFunction, Duration, ScheduledExecutorService, Executor)
instead.
unitSupplier - function that provides the unit element
(i.e. initial value for accumulation) of type Ureduction - function to add an event to the accumulated value.timeout - the maximum time difference between two subsequent
events that can still be accumulated.reduceSuccessions(Function, BiFunction, Duration)default AwaitingEventStream<T> reduceSuccessions(java.util.function.BinaryOperator<T> reduction, java.time.Duration timeout, java.util.concurrent.ScheduledExecutorService scheduler, java.util.concurrent.Executor eventThreadExecutor)
reduceSuccessions(BinaryOperator, Duration)
to use outside of JavaFX application thread.reduction - function to reduce two events into one.timeout - the maximum time difference between two subsequent
events that can still be accumulated.scheduler - used to schedule timeout expirationeventThreadExecutor - executor that executes actions on the
thread on which this stream's events are emitted. The returned stream
will use this executor to emit events.default <U> AwaitingEventStream<U> reduceSuccessions(java.util.function.Function<? super T,? extends U> initialTransformation, java.util.function.BiFunction<? super U,? super T,? extends U> reduction, java.time.Duration timeout, java.util.concurrent.ScheduledExecutorService scheduler, java.util.concurrent.Executor eventThreadExecutor)
reduceSuccessions(Function, BiFunction, Duration)
to use outside of JavaFX application thread.initialTransformation - function to transform a single event
from this stream to an event that can be emitted from the returned
stream.reduction - function to accumulate an event to the stored valuetimeout - the maximum time difference between two subsequent
events that can still be accumulated.scheduler - used to schedule timeout expirationeventThreadExecutor - executor that executes actions on the
thread on which this stream's events are emitted. The returned stream
will use this executor to emit events.default <U> AwaitingEventStream<U> reduceSuccessions(java.util.function.Supplier<? extends U> unitSupplier, java.util.function.BiFunction<? super U,? super T,? extends U> reduction, java.time.Duration timeout, java.util.concurrent.ScheduledExecutorService scheduler, java.util.concurrent.Executor eventThreadExecutor)
reduceSuccessions(Supplier, BiFunction, Duration)
to use outside of JavaFX application thread.unitSupplier - function that provides the unit elementreduction - function to accumulate an event to the stored valuetimeout - the maximum time difference between two subsequent
events that can still be accumulated.scheduler - used to schedule timeout expirationeventThreadExecutor - executor that executes actions on the
thread on which this stream's events are emitted. The returned stream
will use this executor to emit events.default AwaitingEventStream<T> successionEnds(java.time.Duration timeout)
timeout: time gap between two successive events must
be at most timeout.
This method is a shortcut for
reduceSuccessions((a, b) -> b, timeout).
Note: This function can be used only when this stream and
the returned stream are used from the JavaFX application thread. If
you are using the event streams on a different thread, use
successionEnds(Duration, ScheduledExecutorService, Executor)
instead.
timeout - the maximum time difference between two subsequent events
in a close succession.default AwaitingEventStream<T> successionEnds(java.time.Duration timeout, java.util.concurrent.ScheduledExecutorService scheduler, java.util.concurrent.Executor eventThreadExecutor)
successionEnds(Duration) to use outside of JavaFX
application thread.timeout - the maximum time difference between two subsequent events
in a close succession.scheduler - used to schedule timeout expirationeventThreadExecutor - executor that executes actions on the
thread on which this stream's events are emitted. The returned stream
will use this executor to emit events.default <A> AwaitingEventStream<T> thenAccumulateFor(java.time.Duration duration, java.util.function.Function<? super T,? extends A> initialTransformation, java.util.function.BiFunction<? super A,? super T,? extends A> reduction, java.util.function.Function<? super A,java.util.List<T>> deconstruction)
initialTransformation. Any further events that still
arrive within duration are accumulated to the accumulator value
using the given reduction function. After duration has passed
since the last emitted event, the accumulator value is deconstructed
into a series of events using the given deconstruction function
and these events are emitted, the accumulator value is cleared and any
events that arrive within duration are accumulated, and so on.default <A> AwaitingEventStream<T> thenAccumulateFor(java.time.Duration duration, java.util.function.Function<? super T,? extends A> initialTransformation, java.util.function.BiFunction<? super A,? super T,? extends A> reduction, java.util.function.Function<? super A,java.util.List<T>> deconstruction, java.util.concurrent.ScheduledExecutorService scheduler, java.util.concurrent.Executor eventThreadExecutor)
default <A> AwaitingEventStream<T> thenAccumulateFor(java.time.Duration duration, java.util.function.Supplier<? extends A> unit, java.util.function.BiFunction<? super A,? super T,? extends A> reduction, java.util.function.Function<? super A,java.util.List<T>> deconstruction)
thenAccumulateFor(Duration, Function, BiFunction, Function)
for cases when it is more convenient to provide a unit element for
accumulation than the initial transformation.default <A> AwaitingEventStream<T> thenAccumulateFor(java.time.Duration duration, java.util.function.Supplier<? extends A> unit, java.util.function.BiFunction<? super A,? super T,? extends A> reduction, java.util.function.Function<? super A,java.util.List<T>> deconstruction, java.util.concurrent.ScheduledExecutorService scheduler, java.util.concurrent.Executor eventThreadExecutor)
default AwaitingEventStream<T> thenReduceFor(java.time.Duration duration, java.util.function.BinaryOperator<T> reduction)
duration has
passed. Then again, any events that arrive within duration are
reduced into a single event, that is emitted after duration has
passed, and so on.default AwaitingEventStream<T> thenReduceFor(java.time.Duration duration, java.util.function.BinaryOperator<T> reduction, java.util.concurrent.ScheduledExecutorService scheduler, java.util.concurrent.Executor eventThreadExecutor)
default AwaitingEventStream<T> thenRetainLatestFor(java.time.Duration duration)
default AwaitingEventStream<T> thenRetainLatestFor(java.time.Duration duration, java.util.concurrent.ScheduledExecutorService scheduler, java.util.concurrent.Executor eventThreadExecutor)
default AwaitingEventStream<T> thenIgnoreFor(java.time.Duration duration)
default AwaitingEventStream<T> thenIgnoreFor(java.time.Duration duration, java.util.concurrent.ScheduledExecutorService scheduler, java.util.concurrent.Executor eventThreadExecutor)
default <A> EventStream<T> onRecurseAccumulate(java.util.function.Function<? super T,? extends A> initialTransformation, java.util.function.BiFunction<? super A,? super T,? extends A> reduction, java.util.function.Function<? super A,AccumulatorSize> size, java.util.function.Function<? super A,? extends T> head, java.util.function.Function<? super A,? extends A> tail)
default <A> EventStream<T> onRecurseAccumulate(java.util.function.Supplier<? extends A> unit, java.util.function.BiFunction<? super A,? super T,? extends A> reduction, java.util.function.Function<? super A,AccumulatorSize> size, java.util.function.Function<? super A,? extends T> head, java.util.function.Function<? super A,? extends A> tail)
default EventStream<T> onRecurseReduce(java.util.function.BinaryOperator<T> reduction)
default EventStream<T> onRecurseQueue()
default EventStream<T> onRecurseRetainLatest()
default EventStream<T> threadBridge(java.util.concurrent.Executor sourceThreadExecutor, java.util.concurrent.Executor targetThreadExecutor)
sourceThreadExecutor - executor that executes tasks on the thread
from which this EventStream is accessed.targetThreadExecutor - executor that executes tasks on the thread
from which the returned EventStream will be accessed.targetThreadExecutor to emit the events.default EventStream<T> threadBridgeFromFx(java.util.concurrent.Executor targetThreadExecutor)
threadBridge(Platform::runLater, targetThreadExecutor).targetThreadExecutor - executor that executes tasks on the thread
from which the returned EventStream will be accessed.targetThreadExecutor to emit the events.threadBridge(Executor, Executor)default EventStream<T> threadBridgeToFx(java.util.concurrent.Executor sourceThreadExecutor)
threadBridge(sourceThreadExecutor, Platform::runLater).sourceThreadExecutor - executor that executes tasks on the thread
from which this EventStream is accessed.threadBridge(Executor, Executor)@Deprecated default EventStream<T> guardedBy(Guardian... guardians)
suspenderOf(Suspendable) instead.@Experimental default <S extends Suspendable> SuspenderStream<T,S> suspenderOf(S suspendable)
Experimental. The method itself is not experimental,
but the return type SuspenderStream is. You may want to
assign the result to a variable of type EventStream<T> to remain
source compatible if the experimenal SuspenderStream is
removed in the future.