|
Event Dispatcher
v0.1.6-beta.1
Project that offers a small library that allows to subscribe and fire events.
|
Class that allows to register and notify event listeners.
| <T> | the listener type that will provide the notification method |
Definition at line 15 of file EventPublisher.java.
Inheritance diagram for EventPublisher< T >:Public Member Functions | |
| T | registerListener (T listener) |
| void | unregisterListener (T listener) |
| void | unregisterAllListeners () |
| void | notifyListeners (Consumer<? super T > action) |
Protected Attributes | |
| final Lock | readLock = readWriteLock.readLock() |
| final Lock | writeLock = readWriteLock.writeLock() |
Private Attributes | |
| final ReadWriteLock | readWriteLock = new ReentrantReadWriteLock(true) |
| List< T > | listeners = new ArrayList<>() |
| T registerListener | ( | T | listener | ) |
Adds the specified listener to the list of registered listeners.
| listener | the listener that will be called |
Definition at line 29 of file EventPublisher.java.
| void unregisterListener | ( | T | listener | ) |
Removes the first occurrence of the specified listener from the list of the registered listeners.
| listener | the listener that should be removed from the list |
Definition at line 50 of file EventPublisher.java.
| void unregisterAllListeners | ( | ) |
Removes all the listeners from the list of the registered listeners.
The list will be empty after this call returns.
Definition at line 68 of file EventPublisher.java.
| void notifyListeners | ( | Consumer<? super T > | action | ) |
Notifies and executes on each of the registered listeners the provided function.
| action | operation that accepts a single input argument and returns no result |
Definition at line 88 of file EventPublisher.java.
|
private |
Definition at line 17 of file EventPublisher.java.
|
protected |
Definition at line 18 of file EventPublisher.java.
|
protected |
Definition at line 19 of file EventPublisher.java.
|
private |
Definition at line 21 of file EventPublisher.java.