public final class EventSystem
extends java.lang.Object
getInstance().
The event system can be used to send events to other parts of the application an decouple a big app by doing so.
Events can be send synchron (on the JavaFX Application Thread) or asynchron (on a background thread). Each event
will contain content (any Java object) as data for the receiver. When sending an event an adress must be specified.
Several receiver can be registered for an adress. In this case all receivers will get the event.| ?????? | ????? |
|---|---|
void |
addBroadcastReceiver(java.util.function.Consumer<Event> receiver,
io.datafx.core.concurrent.ThreadType type)
Registers a receiver for all broadcast events.
|
void |
addReceiver(java.lang.String address,
java.util.function.Consumer<Event> receiver,
io.datafx.core.concurrent.ThreadType type)
Registers a receiver for all events that will be send to the given adress.
|
static EventSystem |
getInstance()
Returns the event system instance.
|
void |
removeBroadcastReceiver(java.util.function.Consumer<Event> receiver)
Deregisters the receiver
|
void |
removeReceiver(java.lang.String address,
java.util.function.Consumer<Event> receiver)
Deregisters the receiver for the given adress.
|
<T> javafx.concurrent.Worker<java.lang.Void> |
send(java.lang.String address,
T content)
Send an event to all receivers that are registered for the given address.
|
<T> javafx.concurrent.Worker<java.lang.Void> |
sendBroadcast(T content)
Send a broadcast event to all receivers that are registered to receive broadcast events.
|
<T> javafx.concurrent.Worker<java.lang.Void> |
sendBroadcastEvent(Event<T> event)
Send a broadcast event to all receivers that are registered to receive broadcast events.
|
<T> javafx.concurrent.Worker<java.lang.Void> |
sendEvent(java.lang.String address,
Event<T> event)
Send an event to all receivers that are registered for the given address.
|
public static EventSystem getInstance()
public <T> javafx.concurrent.Worker<java.lang.Void> send(java.lang.String address,
T content)
T - content typeaddress - The adresscontent - the contentpublic <T> javafx.concurrent.Worker<java.lang.Void> sendEvent(java.lang.String address,
Event<T> event)
T - content typeaddress - The adressevent - the eventpublic <T> javafx.concurrent.Worker<java.lang.Void> sendBroadcast(T content)
send(String, Object)T - content typecontent - the contentpublic <T> javafx.concurrent.Worker<java.lang.Void> sendBroadcastEvent(Event<T> event)
sendBroadcast(Object)T - the content typeevent - the eventpublic void addReceiver(java.lang.String address,
java.util.function.Consumer<Event> receiver,
io.datafx.core.concurrent.ThreadType type)
address - the adressreceiver - the receivertype - defines if the receiver will get the events on the JavaFX application thread or on
a background thread.public void addBroadcastReceiver(java.util.function.Consumer<Event> receiver, io.datafx.core.concurrent.ThreadType type)
receiver - the receivertype - defines if the receiver will get the events on the JavaFX application thread or on
a background thread.public void removeReceiver(java.lang.String address,
java.util.function.Consumer<Event> receiver)
address - the adressreceiver - the receiverpublic void removeBroadcastReceiver(java.util.function.Consumer<Event> receiver)
receiver - the receiver