A0
- the class of the first argument sent to the listenerpublic class EmitListenerList<A0> extends Object implements Emit.IListenerList<A0>
Uses a CopyOnWriteArrayList. Order of addition is preserved. You can generally NOT add a listener twice - see allowDuplicates
Normally clients don't use this directly, they use Emitter which fires multiple event types
Modifier and Type | Field and Description |
---|---|
protected boolean |
allowDuplicates |
protected Collection<Emit.IListener<A0>> |
listeners |
protected Collection<Emit.IListener<A0>> |
onces |
Constructor and Description |
---|
EmitListenerList(boolean allowDuplicates)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(Emit.IListener<A0> listener) |
protected Collection<Emit.IListener<A0>> |
createCollection()
This is a good implementation, but subclasses might want to override...
|
boolean |
emit(A0 arg0,
Object... more)
Fires the event/object
|
int |
listenerCount()
Current number of listeners
|
Collection<Emit.IListener<A0>> |
listeners()
Returns the raw listeners, use with extreme caution
|
void |
on(Emit.IListener<A0> listener)
Add a listener
|
void |
once(Emit.IListener<A0> listener)
Add a listener that will be triggered only once
|
void |
removeAllListeners()
Remove all listeners
|
void |
removeListener(Emit.IListener<A0> listener)
Remove the listener, from onces and listeners
|
protected Collection<Emit.IListener<A0>> listeners
protected Collection<Emit.IListener<A0>> onces
protected boolean allowDuplicates
public EmitListenerList(boolean allowDuplicates)
allowDuplicates
- public void on(Emit.IListener<A0> listener)
on
in interface Emit.IListenerList<A0>
listener
- if null nothing happens.public void addListener(Emit.IListener<A0> listener)
addListener
in interface Emit.IListenerList<A0>
public void once(Emit.IListener<A0> listener)
once
in interface Emit.IListenerList<A0>
listener
- if null nothing happens.public void removeListener(Emit.IListener<A0> listener)
removeListener
in interface Emit.IListenerList<A0>
listener
- if null nothing happens. They expect an public void removeAllListeners()
removeAllListeners
in interface Emit.IListenerList<A0>
public boolean emit(A0 arg0, Object... more)
emit
in interface Emit.IListenerList<A0>
arg0
- hopefully an more
- may be an empty arraypublic int listenerCount()
listenerCount
in interface Emit.IListenerList<A0>
public Collection<Emit.IListener<A0>> listeners()
listeners
in interface Emit.IListenerList<A0>
protected Collection<Emit.IListener<A0>> createCollection()