Package org.reactfx
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 A
private final AccumulationFacility
<T, A> private boolean
private final EventStream
<T> private int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SuspendableBase
(EventStream<T> input, NotificationAccumulator<O, T, A> pn) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
handleEvent
(T event) protected abstract T
protected A
initialAccumulator
(T value) protected final boolean
protected final Subscription
Starts observing this observable's input(s), if any.protected A
private void
reset()
private void
resume()
protected abstract AccumulatorSize
final Guard
suspend()
Suspends this suspendable object.protected abstract A
Methods inherited from class org.reactfx.ObservableBase
addObserver, enqueueNotifications, equals, forEachObserver, getObserverCount, hashCode, isObservingInputs, newObserver, notifyObservers, notifyObservers, observe, removeObserver, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.reactfx.ProperObservable
defaultEquals, defaultHashCode, defaultNotificationAccumulator, defaultToString
Methods inherited from interface org.reactfx.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:Suspendable
Suspends 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:
suspend
in 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
Guard
isAutoCloseable
, which makes it convenient to use in try-with-resources.
-
observeInputs
Description copied from class:ObservableBase
Starts 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:
observeInputs
in 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
-