Package com.tenio.event.external
Class TEventManager
- java.lang.Object
-
- com.tenio.logger.AbstractLogger
-
- com.tenio.event.external.TEventManager
-
public final class TEventManager extends AbstractLogger
This class for managing events and these subscribers.- Author:
- kong
-
-
Constructor Summary
Constructors Constructor Description TEventManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear all subscribers and these corresponding events.java.lang.Object
emit(TEvent type, java.lang.Object... args)
Emit an event with its parameters.boolean
hasSubscriber(TEvent type)
Check if an event has any subscribers or not.void
on(TEvent type, ISubscriber sub)
Add a subscriber's handler.void
subscribe()
Collect all subscribers and these corresponding events.
-
-
-
Method Detail
-
emit
public java.lang.Object emit(TEvent type, java.lang.Object... args)
Emit an event with its parameters.- Parameters:
type
- seeTEvent
args
- a list parameters of this event- Returns:
- the event result (the response of its subscribers), see
Object
or null - See Also:
TEventProducer.emit(TEvent, Object...)
-
on
public void on(TEvent type, ISubscriber sub)
Add a subscriber's handler.- Parameters:
type
- seeTEvent
sub
- seeISubscriber
-
subscribe
public void subscribe()
Collect all subscribers and these corresponding events.
-
hasSubscriber
public boolean hasSubscriber(TEvent type)
Check if an event has any subscribers or not.- Parameters:
type
- seeTEvent
- Returns:
- true if an event has any subscribers
-
clear
public void clear()
Clear all subscribers and these corresponding events.
-
-