Class LinkedPublisher<T>
java.lang.Object
dev.getelements.elements.sdk.util.AbstractPublisher<T>
dev.getelements.elements.sdk.util.LinkedPublisher<T>
- Type Parameters:
T
- the type of event to publish
A non-threadsafe publisher which tracks subscribers in a linked list. For the purposes of debugging this implements
Iterable
which most IDEs will recognize and render as sequence in the debugger.-
Field Summary
Fields inherited from class dev.getelements.elements.sdk.util.AbstractPublisher
logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears allSubscription
s and implicitly removes them from the internal pool.iterator()
Used only to facilitate debugging.void
Publishes the supplied event synchronously and calls theConsumer
when allSubscription
s have been notified.subscribe
(BiConsumer<Subscription, ? super T> consumer) Subscribes to a particular event.Methods inherited from class dev.getelements.elements.sdk.util.AbstractPublisher
handleException, logException, publish, publish
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LinkedPublisher
public LinkedPublisher() -
LinkedPublisher
public LinkedPublisher(org.slf4j.Logger logger)
-
-
Method Details
-
subscribe
Description copied from interface:Publisher
Subscribes to a particular event. The suppliedBiConsumer
will receive zero or more events in the future until the associated call toSubscription.unsubscribe()
.- Specified by:
subscribe
in interfacePublisher<T>
- Parameters:
consumer
- theBiConsumer
which will accept event- Returns:
- the
Subscription
-
clear
public void clear()Description copied from interface:Publisher
Clears allSubscription
s and implicitly removes them from the internal pool. Implementing this interface method is optional, and therefore this may throw an instance ofUnsupportedOperationException
. -
publish
Description copied from interface:Publisher
Publishes the supplied event synchronously and calls theConsumer
when allSubscription
s have been notified. Additionally, this notifies for every exception thrown in the process. -
iterator
Used only to facilitate debugging. The returned Objects are internal implementation details and not intended to be used to execute business logic of the application.
-