Package net.phoenix
Class EventEmitter<T extends Event>
java.lang.Object
net.phoenix.EventEmitter<T>
- Type Parameters:
T
- Event type. Either should be a class that extends Event OR a generic type (EventEmitter<? extends Event>)
Standard event emitter class
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAwaits for a method under the global channelvoid
Calls all the events under a channelvoid
Awaits for a method under the global channelvoid
Disable a eventHandlerRegister an event handler with default priority of LOWon
(String channel, Callback<T> callback, EventEmitter.Priority priority) Register an event handler with a custom priorityAwaits for a method under the global channelon
(Callback<T> callback, EventEmitter.Priority priority) Awaits for a method under the global channel
-
Constructor Details
-
EventEmitter
public EventEmitter()
-
-
Method Details
-
emit
Calls all the events under a channel- Parameters:
channel
- Channel to send eventobject
- Instance of event to send- Throws:
IllegalArgumentException
- Throws exception if the event passed is different to the EventHandler type
-
on
Awaits for a method under the global channel- Throws:
IllegalArgumentException
- Throws exception if the event passed is different to the EventHandler type
-
on
Awaits for a method under the global channel- Throws:
IllegalArgumentException
- Throws exception if the event passed is different to the EventHandler type
-
emit
Awaits for a method under the global channel- Throws:
IllegalArgumentException
- Throws exception if the event passed is different to the EventHandler type
-
on
Register an event handler with default priority of LOW- Parameters:
channel
- The channel you want to listen forcallback
- Event handler. Can be used as a lambda; (channel, event) -> {}- Returns:
- Event handler UUID used in off()
- See Also:
-
on
Register an event handler with a custom priority- Parameters:
channel
- The channel you want to listen forcallback
- Event handler. Can be used as a lambda; (channel, event) -> {}priority
- Priority level- Returns:
- Event handler UUID used in off()
- See Also:
-
await
Awaits for a method under the global channel- Throws:
InterruptedException
- Throws exception if the thread is interrupted
-
off
Disable a eventHandler- Parameters:
uuid
- UUID of event handler to remove. UUID is the value returned by EventEmitter#on
-