T - Type of listener to store.public final class ListenersHolder<T extends EventListener> extends java.lang.Object implements EventSource<T>, EventPublisher
EventListener providing utility methods for any EventSource implementation that
requires storing and invoking listeners.| Constructor and Description |
|---|
ListenersHolder() |
ListenersHolder(ListenersHolder<T> toCopy) |
| Modifier and Type | Method and Description |
|---|---|
ListenersHolder<T> |
copy() |
void |
dispose() |
void |
invokeListeners(rx.functions.Action1<T> invocationAction)
Invoke listeners with an action expressed by the passed
invocationAction. |
<A> void |
invokeListeners(rx.functions.Action2<T,A> invocationAction,
A arg)
Invoke listeners with an action expressed by the passed
invocationAction. |
void |
invokeListeners(rx.functions.Action3<T,java.lang.Long,java.util.concurrent.TimeUnit> invocationAction,
long duration,
java.util.concurrent.TimeUnit timeUnit)
Invoke listeners with an action expressed by the passed
invocationAction. |
<A> void |
invokeListeners(rx.functions.Action3<T,java.lang.Throwable,A> invocationAction,
java.lang.Throwable throwable,
A arg)
Invoke listeners with an action expressed by the passed
invocationAction. |
<A> void |
invokeListeners(rx.functions.Action4<T,java.lang.Long,java.util.concurrent.TimeUnit,A> invocationAction,
long duration,
java.util.concurrent.TimeUnit timeUnit,
A arg)
Invoke listeners with an action expressed by the passed
invocationAction. |
void |
invokeListeners(rx.functions.Action4<T,java.lang.Long,java.util.concurrent.TimeUnit,java.lang.Throwable> invocationAction,
long duration,
java.util.concurrent.TimeUnit timeUnit,
java.lang.Throwable throwable)
Invoke listeners with an action expressed by the passed
invocationAction. |
<A> void |
invokeListeners(rx.functions.Action5<T,java.lang.Long,java.util.concurrent.TimeUnit,java.lang.Throwable,A> invocationAction,
long duration,
java.util.concurrent.TimeUnit timeUnit,
java.lang.Throwable throwable,
A arg)
Invoke listeners with an action expressed by the passed
invocationAction. |
boolean |
publishingEnabled()
Returns
true if event publishing is enabled. |
rx.Subscription |
subscribe(T listener)
Subscribes the passed
listener for events published by this source. |
void |
subscribeAllTo(EventSource<T> lazySource) |
public ListenersHolder()
public ListenersHolder(ListenersHolder<T> toCopy)
public rx.Subscription subscribe(T listener)
EventSourcelistener for events published by this source.subscribe in interface EventSource<T extends EventListener>listener - Listener for events published by this source.public boolean publishingEnabled()
EventPublishertrue if event publishing is enabled. This is primarily used to short-circuit event publishing
if the publishing is not enabled. Event publishing will be disabled if there are no active listeners or has
been explicitly disabled using RxNetty.disableEventPublishing()publishingEnabled in interface EventPublishertrue if event publishing is enabled.public void dispose()
public void invokeListeners(rx.functions.Action1<T> invocationAction)
invocationAction. This method does the necessary
validations required for invoking a listener and also guards against a listener throwing exceptions on invocation.invocationAction - The action to perform on all listeners.public void invokeListeners(rx.functions.Action3<T,java.lang.Long,java.util.concurrent.TimeUnit> invocationAction, long duration, java.util.concurrent.TimeUnit timeUnit)
invocationAction. This method does the necessary
validations required for invoking a listener and also guards against a listener throwing exceptions on invocation.invocationAction - The action to perform on all listeners.duration - Duration.timeUnit - Time unit for the duration.public void invokeListeners(rx.functions.Action4<T,java.lang.Long,java.util.concurrent.TimeUnit,java.lang.Throwable> invocationAction, long duration, java.util.concurrent.TimeUnit timeUnit, java.lang.Throwable throwable)
invocationAction. This method does the necessary
validations required for invoking a listener and also guards against a listener throwing exceptions on invocation.invocationAction - The action to perform on all listeners.duration - Duration.timeUnit - Time unit for the duration.throwable - An error.public <A> void invokeListeners(rx.functions.Action4<T,java.lang.Long,java.util.concurrent.TimeUnit,A> invocationAction, long duration, java.util.concurrent.TimeUnit timeUnit, A arg)
invocationAction. This method does the necessary
validations required for invoking a listener and also guards against a listener throwing exceptions on invocation.invocationAction - The action to perform on all listeners.duration - Duration.timeUnit - Time unit for the duration.arg - Any arbitrary argumentpublic <A> void invokeListeners(rx.functions.Action5<T,java.lang.Long,java.util.concurrent.TimeUnit,java.lang.Throwable,A> invocationAction, long duration, java.util.concurrent.TimeUnit timeUnit, java.lang.Throwable throwable, A arg)
invocationAction. This method does the necessary
validations required for invoking a listener and also guards against a listener throwing exceptions on invocation.invocationAction - The action to perform on all listeners.duration - Duration.timeUnit - Time unit for the duration.throwable - An error.arg - Any arbitrary argumentpublic <A> void invokeListeners(rx.functions.Action2<T,A> invocationAction, A arg)
invocationAction. This method does the necessary
validations required for invoking a listener and also guards against a listener throwing exceptions on invocation.invocationAction - The action to perform on all listeners.arg - Any arbitrary argumentpublic <A> void invokeListeners(rx.functions.Action3<T,java.lang.Throwable,A> invocationAction, java.lang.Throwable throwable, A arg)
invocationAction. This method does the necessary
validations required for invoking a listener and also guards against a listener throwing exceptions on invocation.invocationAction - The action to perform on all listeners.throwable - An error.arg - Any arbitrary argumentpublic ListenersHolder<T> copy()
public void subscribeAllTo(EventSource<T> lazySource)