public abstract class AbstractComponent extends java.lang.Object implements Component
Modifier and Type | Field and Description |
---|---|
protected EventEmitter |
eventEmitter |
protected java.util.Map<java.lang.String,java.lang.Integer> |
listenerTokens |
Constructor and Description |
---|
AbstractComponent(EventEmitter eventEmitter)
Build an AbstractComponent that does not use a registering event emitter.
|
AbstractComponent(EventEmitter eventEmitter,
java.lang.Class<? extends Component> componentClass)
Being Components, Controllers inheriting from AbstractController require an EventEmitter on
initialization.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(java.lang.String eventType,
EventListener listener)
Convenience method to add an EventListener for the given type using the EventEmitter.on()
method.
|
void |
addOnceListener(java.lang.String eventType,
EventListener listener)
Convenience method to add an EventListener for the given type using the EventEmitter.once()
method.
|
EventEmitter |
getEventEmitter()
Provides a reference to the EventEmitter with which this component was initialized
|
void |
removeListener(java.lang.String eventType)
Removes the specified listener from the EventEmitter.
|
void |
removeListeners()
Removes all set listeners from the EventEmitter.
|
protected EventEmitter eventEmitter
protected java.util.Map<java.lang.String,java.lang.Integer> listenerTokens
public AbstractComponent(EventEmitter eventEmitter, java.lang.Class<? extends Component> componentClass)
eventEmitter
- the EventEmitter through which this Component will listen for and emit
events to interact with other components in the playerpublic AbstractComponent(EventEmitter eventEmitter)
eventEmitter
- the EventEmitter through which this Component will listen for and emit
events to interact with other components in the playerpublic void addListener(java.lang.String eventType, EventListener listener)
eventType
- the EventType for which the listener should be calledlistener
- the implementation of EventListener for this EventTypepublic void addOnceListener(java.lang.String eventType, EventListener listener)
eventType
- the EventType for which the listener should be calledlistener
- the implementation of EventListener for this EventTypepublic void removeListener(java.lang.String eventType)
eventType
- the EventType for which the listener should be calledpublic void removeListeners()
public EventEmitter getEventEmitter()