Top Description Methods
org.reactfx

public Interface EventStream<T>

extends Observable<Consumer<? super T>>
Known Direct Subinterfaces
org.reactfx.SuspendableEventStream, org.reactfx.SuspenderStream, org.reactfx.TaskStream, org.reactfx.ProperEventStream, org.reactfx.AwaitingEventStream, org.reactfx.CompletionStageStream, org.reactfx.ConnectableEventStream
Known Direct Implementers
org.reactfx.EventStreams.Never
Type Parameters
<T>
type of values emitted by this stream.
Static Imports
org.reactfx.EventStreams.*, org.reactfx.util.Tuples.*

Stream of values (events).

Method Summary

Modifier and TypeMethod and Description
public default EventStream<T>
accumulate(BinaryOperator<T>
function to reduce two events into one.
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.

public default <U> EventStream<U>
accumulate(U
initial value of the accumulated value.
unit
,
BiFunction<? super U, ? super T, ? extends U>
function to add an event to the accumulated value.
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.

public default <U> EventStream<U>
accumulate(BiFunction<? super U, ? super T, ? extends U>
function to add an event to the accumulated value.
reduction
,
Function<? super T, ? extends U>
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.
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.

public default <A> EventStream<T>
accumulateBetween(EventStream<?> ticks, Function<? super T, ? extends A> initialTransformation, BiFunction<? super A, ? super T, ? extends A> accumulation, Function<? super A, 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.

public default <A> EventStream<T>
accumulateBetween(EventStream<?> ticks, Supplier<? extends A> unit, BiFunction<? super A, ? super T, ? extends A> accumulation, Function<? super A, 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.

public default <A> EventStream<T>
accumulateUntilLater(Function<? super T, ? extends A> initialTransformation, BiFunction<? super A, ? super T, ? extends A> accumulation, Function<? super A, List<T>> deconstruction, Executor
executor that executes actions on the thread from which this event stream is accessed.
eventThreadExecutor
)

Version of accumulateUntilLater(Function, BiFunction, Function) for event streams that don't live on the JavaFX application thread.

public default <
type of the cumulative value (accumulator)
A
>
EventStream<T>
accumulateUntilLater(Function<? super T, ? extends A> initialTransformation, BiFunction<? super A, ? super T, ? extends A> accumulation, Function<? super A, 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.

public default <A> EventStream<T>
accumulateUntilLater(Supplier<? extends A> unit, BiFunction<? super A, ? super T, ? extends A> accumulation, Function<? super A, List<T>> deconstruction, Executor
executor that executes actions on the thread from which this event stream is accessed.
eventThreadExecutor
)

Version of accumulateUntilLater(Supplier, BiFunction, Function) for event streams that don't live on the JavaFX application thread.

public default <
type of the cumulative value (accumulator)
A
>
EventStream<T>
accumulateUntilLater(Supplier<? extends A> unit, BiFunction<? super A, ? super T, ? extends A> accumulation, Function<? super A, 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.

public default <A> EventStream<T>
accumulateWhen(ObservableValue<Boolean> condition, Function<? super T, ? extends A> initialTransformation, BiFunction<? super A, ? super T, ? extends A> accumulation, Function<? super A, AccumulatorSize> size, Function<? super A, ? extends T> head, Function<? super A, ? extends A> tail)

Shortcut for

accumulative(initialTransformation, accumulation, size, head, tail)
    .suspendedWhen(condition)
public default <A> EventStream<T>
accumulateWhen(ObservableValue<Boolean> condition, Supplier<? extends A> unit, BiFunction<? super A, ? super T, ? extends A> accumulation, Function<? super A, AccumulatorSize> size, Function<? super A, ? extends T> head, Function<? super A, ? extends A> tail)

Shortcut for

accumulative(unit, accumulation, size, head, tail)
    .suspendedWhen(condition)
public default <
type of the cumulative value
A
>
SuspendableEventStream<T>
accumulative(Function<? super T, ? extends A>
Used to convert the first event after suspension to the cumulative value.
initialTransformation
,
BiFunction<? super A, ? super T, ? extends A>
Used to accumulate further incoming events to the cumulative value.
accumulation
,
Function<? super A, AccumulatorSize>
determines how many events can be emitted from the current cumulative value.
size
,
Function<? super A, ? extends T>
produces the first event off the cumulative value.
head
,
Function<? super A, ? extends A>
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.
tail
)

Returns a suspendable event stream that, when suspended, accumulates incoming events to a cumulative value of type A.

public default <
type of the cumulative value
A
>
SuspendableEventStream<T>
accumulative(Supplier<? extends A>
Function that supplies unit element of the accumulation.
unit
,
BiFunction<? super A, ? super T, ? extends A>
Used to accumulate further incoming events to the cumulative value.
accumulation
,
Function<? super A, AccumulatorSize>
determines how many events can be emitted from the current cumulative value.
size
,
Function<? super A, ? extends T>
produces the first event off the cumulative value.
head
,
Function<? super A, ? extends A>
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.
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.

public default <U extends T> EventStream<U>
cast(Class<U> subtype)

Returns a new event stream that emits events emitted by this stream cast to the given type.

public default EventStream<T>
conditionOn(ObservableValue<Boolean> condition)

Returns a new EventStream that only observes this EventStream when condition is true.

public default EventStream<T>
conditionOnShowing(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).

public default EventStream<T>
distinct()

Returns a new event stream that emits repetitive events only once.

public default <I> EventStream<Tuple2<T, I>>
emitBothOnEach(EventStream<I> impulse)

Similar to emitOnEach(EventStream), but also includes the impulse in the emitted value.

public 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.

public 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.

public default Subscription

Returns:

subscription that can be used to stop delivering this stream's events to sink.
feedTo
(EventSink<? super T>
event sink to which this event stream's events will be pushed
sink
)

Starts pushing all events emitted by this stream to the given event sink.

public default Subscription
feedTo(WritableValue<? super T> dest)

Starts setting all events emitted by this stream as the value of the given writable value.

public default EventStream<T>
filter(Predicate<? super T> predicate)

Returns a new event stream that emits events emitted from this stream that satisfy the given predicate.

public default <U extends T> EventStream<U>
filter(Class<U> subtype)

Filters this event stream by the runtime type of the values.

public default <U> EventStream<U>
filterMap(Predicate<? super T> predicate, Function<? super T, ? extends U> f)

A more efficient equivalent to filter(predicate).map(f).

public default <U> EventStream<U>
filterMap(Function<? super T, Optional<U>> f)

Equivalent to

map(f)
    .filter(Optional::isPresent)
    .map(Optional::get)

public default <U> EventStream<U>
flatMap(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.

public default SuspendableEventStream<T>
forgetful()

Returns a suspendable event stream that, when suspended, forgets all but the latest event emitted by this event stream.

public default Tuple2<EventStream<T>, EventStream<T>>
fork(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.

public default EventStream<T>
guardedBy(Guardian... guardians)
Deprecated Use suspenderOf(Suspendable) instead.

Returns a clone of this event stream guarded by the given guardians.

public default EventStream<T>
hook(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.

public default EventStream<List<T>>
latestN(int n)

Returns an event stream that emits lists of n latest events emitted from this stream.

public default <U> EventStream<U>
map(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.

public default <U> CompletionStageStream<U>
mapToCompletionStage(Function<? super T, 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.

public default <U> TaskStream<U>
mapToTask(Function<? super T, 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.

public default <A> EventStream<T>
onRecurseAccumulate(Function<? super T, ? extends A> initialTransformation, BiFunction<? super A, ? super T, ? extends A> reduction, Function<? super A, AccumulatorSize> size, Function<? super A, ? extends T> head, Function<? super A, ? extends A> tail)

public default <A> EventStream<T>
onRecurseAccumulate(Supplier<? extends A> unit, BiFunction<? super A, ? super T, ? extends A> reduction, Function<? super A, AccumulatorSize> size, Function<? super A, ? extends T> head, Function<? super A, ? extends A> tail)

public default EventStream<T>
public default EventStream<T>
public default EventStream<T>
public 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.

public 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.

public default EventStream<T>
pauseWhen(ObservableValue<Boolean> condition)

Shortcut for pausable().suspendedWhen(condition).

public default Subscription

Returns:

subscription used to cancel the pinning
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.

public default EventStream<T>
queueBetween(EventStream<?> ticks)

Returns an event stream that, when an event arrives from this stream, enqueues it for emission.

public default EventStream<T>
queueUntilLater(Executor
executor that executes actions on the thread from which this event stream is accessed.
eventThreadExecutor
)

Version of queueUntilLater() for event streams that don't live on the JavaFX application thread.

public 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.

public default EventStream<T>
reduceBetween(EventStream<?> ticks, BinaryOperator<T> reduction)

Returns an event stream that, when an event arrives from this stream, stores it for emission.

public default AwaitingEventStream<T>
reduceSuccessions(BinaryOperator<T>
function to reduce two events into one.
reduction
,
Duration
the maximum time difference between two subsequent events that can still be accumulated.
timeout
)

Returns an event stream that accumulates events emitted from this event stream in close temporal succession.

public default <
type of events emitted from the returned stream.
U
>
AwaitingEventStream<U>
reduceSuccessions(Function<? super T, ? extends U>
function to transform a single event from this stream to an event that can be emitted from the returned stream.
initialTransformation
,
BiFunction<? super U, ? super T, ? extends U>
function to add an event to the accumulated value.
reduction
,
Duration
the maximum time difference between two subsequent events that can still be accumulated.
timeout
)

A more general version of reduceSuccessions(BinaryOperator, Duration) that allows the accumulated event to be of different type.

public default <U> AwaitingEventStream<U>
reduceSuccessions(Supplier<? extends U>
function that provides the unit element (i.e. initial value for accumulation) of type U
unitSupplier
,
BiFunction<? super U, ? super T, ? extends U>
function to add an event to the accumulated value.
reduction
,
Duration
the maximum time difference between two subsequent events that can still be accumulated.
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.

public default AwaitingEventStream<T>
reduceSuccessions(BinaryOperator<T>
function to reduce two events into one.
reduction
,
Duration
the maximum time difference between two subsequent events that can still be accumulated.
timeout
,
ScheduledExecutorService
used to schedule timeout expiration
scheduler
,
Executor
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.
eventThreadExecutor
)

An analog to reduceSuccessions(BinaryOperator, Duration) to use outside of JavaFX application thread.

public default <U> AwaitingEventStream<U>
reduceSuccessions(Function<? super T, ? extends U>
function to transform a single event from this stream to an event that can be emitted from the returned stream.
initialTransformation
,
BiFunction<? super U, ? super T, ? extends U>
function to accumulate an event to the stored value
reduction
,
Duration
the maximum time difference between two subsequent events that can still be accumulated.
timeout
,
ScheduledExecutorService
used to schedule timeout expiration
scheduler
,
Executor
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.
eventThreadExecutor
)

An analog to reduceSuccessions(Function, BiFunction, Duration) to use outside of JavaFX application thread.

public default <U> AwaitingEventStream<U>
reduceSuccessions(Supplier<? extends U>
function that provides the unit element
unitSupplier
,
BiFunction<? super U, ? super T, ? extends U>
function to accumulate an event to the stored value
reduction
,
Duration
the maximum time difference between two subsequent events that can still be accumulated.
timeout
,
ScheduledExecutorService
used to schedule timeout expiration
scheduler
,
Executor
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.
eventThreadExecutor
)

An analog to reduceSuccessions(Supplier, BiFunction, Duration) to use outside of JavaFX application thread.

public default EventStream<T>
reduceUntilLater(BinaryOperator<T> reduction, Executor
executor that executes actions on the thread from which this event stream is accessed.
eventThreadExecutor
)

Version of reduceUntilLater(BinaryOperator) for event streams that don't live on the JavaFX application thread.

public default EventStream<T>
reduceUntilLater(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.

public default EventStream<T>
reduceWhen(ObservableValue<Boolean> condition, BinaryOperator<T> reduction)

Shortcut for reducible(reduction).suspendedWhen(condition).

public default SuspendableEventStream<T>
reducible(BinaryOperator<T> reduction)

Returns a suspendable event stream that, when suspended, reduces incoming events by the given reduction function into one.

public 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.

public default EventStream<T>
public default EventStream<T>
retainLatestUntilLater(Executor
executor that executes actions on the thread from which this event stream is accessed.
eventThreadExecutor
)

Version of retainLatestUntilLater() for event streams that don't live on the JavaFX application thread.

public 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.

public default EventStream<T>
retainLatestWhen(ObservableValue<Boolean> condition)

Shortcut for forgetful().suspendedWhen(condition).

public default EventStream<Either<T, T>>
splitBy(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.

public default Subscription

Returns:

subscription that can be used to stop observing this event stream.
subscribe
(Consumer<? super T>
handles emitted events.
subscriber
)

Get notified every time this event stream emits a value.

public default Subscription

Returns:

Subscription that may be used to unsubscribe before reaching n events handled by subscriber.
subscribeFor
(int
limit on how many events may be handled by subscriber. Must be positive.
n
,
Consumer<? super T>
handles emitted events.
subscriber
)

Subscribes to this event stream for at most n events.

public default Subscription
subscribeForOne(Consumer<? super T> subscriber)

Shorthand for subscribeFor(1, subscriber).

public default AwaitingEventStream<T>
successionEnds(Duration
the maximum time difference between two subsequent events in a close succession.
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.

public default AwaitingEventStream<T>
successionEnds(Duration
the maximum time difference between two subsequent events in a close succession.
timeout
,
ScheduledExecutorService
used to schedule timeout expiration
scheduler
,
Executor
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.
eventThreadExecutor
)

An analog to successionEnds(Duration) to use outside of JavaFX application thread.

public default <U> EventStream<U>
supply(U value)

Returns an event stream that emits the given constant value every time this stream emits a value.

public default <U> EventStream<U>
supply(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.

public default <U> CompletionStageStream<U>
supplyCompletionStage(Supplier<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.

public default <U> TaskStream<U>
supplyTask(Supplier<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.

public default SuspendableEventStream<T>
suppressible()

Returns a suspendable event stream that, when suspended, suppresses any events emitted by this event stream.

public default EventStream<T>
suppressWhen(ObservableValue<Boolean> condition)

Shortcut for suppressible().suspendedWhen(condition).

public default <S extends Suspendable> SuspenderStream<T, S>
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.

public default <A> AwaitingEventStream<T>
thenAccumulateFor(Duration duration, Function<? super T, ? extends A> initialTransformation, BiFunction<? super A, ? super T, ? extends A> reduction, Function<? super A, 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.

public default <A> AwaitingEventStream<T>
thenAccumulateFor(Duration duration, Function<? super T, ? extends A> initialTransformation, BiFunction<? super A, ? super T, ? extends A> reduction, Function<? super A, List<T>> deconstruction, ScheduledExecutorService scheduler, Executor eventThreadExecutor)

public default <A> AwaitingEventStream<T>
thenAccumulateFor(Duration duration, Supplier<? extends A> unit, BiFunction<? super A, ? super T, ? extends A> reduction, Function<? super A, 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.

public default <A> AwaitingEventStream<T>
thenAccumulateFor(Duration duration, Supplier<? extends A> unit, BiFunction<? super A, ? super T, ? extends A> reduction, Function<? super A, List<T>> deconstruction, ScheduledExecutorService scheduler, Executor eventThreadExecutor)

public default AwaitingEventStream<T>
thenIgnoreFor(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.

public default AwaitingEventStream<T>
thenIgnoreFor(Duration duration, ScheduledExecutorService scheduler, Executor eventThreadExecutor)

public default AwaitingEventStream<T>
thenReduceFor(Duration duration, 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.

public default AwaitingEventStream<T>
thenReduceFor(Duration duration, BinaryOperator<T> reduction, ScheduledExecutorService scheduler, Executor eventThreadExecutor)

public default AwaitingEventStream<T>
thenRetainLatestFor(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.

public default AwaitingEventStream<T>
thenRetainLatestFor(Duration duration, ScheduledExecutorService scheduler, Executor eventThreadExecutor)

public default EventStream<T>

Returns:

Event stream that emits the same events as this EventStream, but uses targetThreadExecutor to emit the events.
threadBridge
(Executor
executor that executes tasks on the thread from which this EventStream is accessed.
sourceThreadExecutor
,
Executor
executor that executes tasks on the thread from which the returned EventStream will be accessed.
targetThreadExecutor
)

Transfers events from one thread to another.

public default EventStream<T>

Returns:

Event stream that emits the same events as this EventStream, but uses targetThreadExecutor to emit the events.
threadBridgeFromFx
(Executor
executor that executes tasks on the thread from which the returned EventStream will be accessed.
targetThreadExecutor
)

Transfers events from the JavaFX application thread to another thread.

public default EventStream<T>

Returns:

Event stream that emits the same events as this EventStream, but emits them on the JavaFX application thread.
threadBridgeToFx
(Executor
executor that executes tasks on the thread from which this EventStream is accessed.
sourceThreadExecutor
)

Transfers events to the JavaFX application thread.

public default Binding<T>

Returns:

binding reflecting the most recently emitted value.
toBinding
(T
used as the returned binding's value until this stream emits the first value.
initialValue
)

Returns a binding that holds the most recent event emitted from this stream.

public default EventStream<T>
withDefaultEvent(T
the event this event stream will emit if something subscribes to this stream and this stream does not have an event.
defaultEvent
)

Returns an event stream that immediately emits its event when something subscribes to it.

Inherited from org.reactfx.Observable:
addObserverobserveremoveObserver