Class EventSignal1<E extends WAbstractEvent>
- java.lang.Object
-
- eu.webtoolkit.jwt.AbstractSignal
-
- eu.webtoolkit.jwt.AbstractEventSignal
-
- eu.webtoolkit.jwt.EventSignal1<E>
-
public final class EventSignal1<E extends WAbstractEvent> extends AbstractEventSignal
A signal which relays a browser event that passes event details. The signal also passes on an event object that provides details of the event.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.AbstractEventSignal
AbstractEventSignal.AutoLearnListener, AbstractEventSignal.JavaScriptListener, AbstractEventSignal.LearningListener, AbstractEventSignal.PreLearnListener
-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.AbstractSignal
AbstractSignal.Connection
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AbstractSignal.ConnectionaddListener(WObject listenerOwner, Signal.Listener listener)Adds a listener for this signal.AbstractSignal.ConnectionaddListener(WObject listenerOwner, Signal1.Listener<E> listener)Adds a listener for this signal.protected intgetArgumentCount()Returns the number of parameters (excluding an 'event').protected intgetListenerCount()Returns the number of connected listeners.voidremoveListener(Signal.Listener listener)Removes a listener.voidremoveListener(Signal1.Listener<E> listener)Removes a listener.voidtrigger(E event)Triggers the signal.-
Methods inherited from class eu.webtoolkit.jwt.AbstractEventSignal
addListener, addListener, addListener, addListener, addListener, addListener, createUserEventCall, disconnect, isCanAutoLearn, isConnected, isDefaultActionPrevented, isPropagationPrevented, preventDefaultAction, preventDefaultAction, preventPropagation, preventPropagation, removeListener, removeListener
-
Methods inherited from class eu.webtoolkit.jwt.AbstractSignal
getListeners, isBlocked, setBlocked
-
-
-
-
Method Detail
-
addListener
public AbstractSignal.Connection addListener(WObject listenerOwner, Signal1.Listener<E> listener)
Adds a listener for this signal. Each listener will be triggered whenever the signal is triggered.- Parameters:
listenerOwner- the enclosing object for a listener implemented by an anonymous inner class.listener- the listener- Returns:
- a connection object that may be used to control the connection
- See Also:
addListener(WObject, Signal.Listener)
-
getListenerCount
protected int getListenerCount()
Description copied from class:AbstractSignalReturns the number of connected listeners.- Overrides:
getListenerCountin classAbstractEventSignal- Returns:
- the number of connected listeners.
-
removeListener
public void removeListener(Signal1.Listener<E> listener)
Removes a listener.- Parameters:
listener- a listener that was previously added
-
trigger
public void trigger(E event)
Triggers the signal. Event details will be passed on to listeners.- Parameters:
event- The event details.
-
addListener
public AbstractSignal.Connection addListener(WObject listenerOwner, Signal.Listener listener)
Description copied from class:AbstractSignalAdds a listener for this signal.Each listener will be notified when the signal is triggered.
An owner object may be passed when the listener is implemented using an (anonymous) inner class. In that case the owner object should be the enclosing object of the listener object, and this is used to bind the lifetime of the listener. To avoid the owner object from not being garbage collected when it is no longer used, only the owner object will add a reference to the listener, while the signal will use a weak reference.
This avoids the most common reason for memory leaks in Java implementations of the Observer pattern: the owner object will not get garbage collected because of the (anonymous) listener object having a reference to it, even if the receiver object is no longer referenced from anywhere. When the owner object is not
null, the listener is stored using a strong reference in the owner object, and using a weak reference in the signal.- Specified by:
addListenerin classAbstractSignal- Parameters:
listenerOwner- if notnull, the enclosing object for a listener implemented using an inner classlistener- the listener- Returns:
- a connection object that may be used to control the connection
-
removeListener
public void removeListener(Signal.Listener listener)
Description copied from class:AbstractSignalRemoves a listener.- Specified by:
removeListenerin classAbstractSignal- Parameters:
listener- a listener that was previously added.
-
getArgumentCount
protected int getArgumentCount()
Description copied from class:AbstractSignalReturns the number of parameters (excluding an 'event').- Specified by:
getArgumentCountin classAbstractSignal
-
-