Class SuspendableBase<O,T,A>
java.lang.Object
org.reactfx.ObservableBase<O,T>
org.reactfx.SuspendableBase<O,T,A>
- All Implemented Interfaces:
Observable<O>, ProperObservable<O,T>, Suspendable
- Direct Known Subclasses:
SuspendableEventStreamBase, SuspendableListWrapper, SuspendableValWrapper
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Aprivate final AccumulationFacility<T, A> private booleanprivate final EventStream<T> private int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSuspendableBase(EventStream<T> input, NotificationAccumulator<O, T, A> pn) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidhandleEvent(T event) protected abstract Tprotected AinitialAccumulator(T value) protected final booleanprotected final SubscriptionStarts observing this observable's input(s), if any.protected Aprivate voidreset()private voidresume()protected abstract AccumulatorSizefinal Guardsuspend()Suspends this suspendable object.protected abstract AMethods inherited from class ObservableBase
addObserver, enqueueNotifications, equals, forEachObserver, getObserverCount, hashCode, isObservingInputs, newObserver, notifyObservers, notifyObservers, observe, removeObserver, toStringMethods inherited from interface ProperObservable
defaultEquals, defaultHashCode, defaultNotificationAccumulator, defaultToStringMethods inherited from interface Suspendable
suspendWhen, suspendWhile, suspendWhile
-
Field Details
-
input
-
af
-
suspended
private int suspended -
hasValue
private boolean hasValue -
accumulatedValue
-
-
Constructor Details
-
SuspendableBase
-
-
Method Details
-
sizeOf
-
headOf
-
tailOf
-
initialAccumulator
-
reduce
-
isSuspended
protected final boolean isSuspended() -
suspend
Description copied from interface:SuspendableSuspends this suspendable object.In case of suspendable
Observable, suspends notification delivery for this observable object. Notifications produced while suspended may be queued for later delivery, accumulated into a single cumulative notification, or discarded completely, depending on the concrete implementation.- Specified by:
suspendin interfaceSuspendable- Returns:
- a Guard instance that can be released to end
suspension. In case of suspended notifications, releasing the returned
Guard will trigger delivery of queued or accumulated
notifications, if any.
The returned
GuardisAutoCloseable, which makes it convenient to use in try-with-resources.
-
observeInputs
Description copied from class:ObservableBaseStarts observing this observable's input(s), if any. This method is called when the number of observers goes from 0 to 1. This method is called beforeObservableBase.newObserver(Object)is called for the first observer.- Specified by:
observeInputsin classObservableBase<O,T> - Returns:
- subscription used to stop observing inputs. The subscription is unsubscribed (i.e. input observation stops) when the number of observers goes down to 0.
-
resume
private void resume() -
reset
private void reset() -
handleEvent
-