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 TypeMethodDescriptionvoidclear()Clears allSubscriptions and implicitly removes them from the internal pool.iterator()Used only to facilitate debugging.voidPublishes the supplied event synchronously and calls theConsumerwhen allSubscriptions 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, publishMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:PublisherSubscribes to a particular event. The suppliedBiConsumerwill receive zero or more events in the future until the associated call toSubscription.unsubscribe().- Specified by:
subscribein interfacePublisher<T>- Parameters:
consumer- theBiConsumerwhich will accept event- Returns:
- the
Subscription
-
clear
public void clear()Description copied from interface:PublisherClears allSubscriptions 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:PublisherPublishes the supplied event synchronously and calls theConsumerwhen allSubscriptions 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.
-