T
- The type of data to utilize in Consumers
.public class Radio<T>
extends java.lang.Object
Radio
class describes an event emitter that can be used for
emitting and listening to events.Constructor and Description |
---|
Radio() |
Modifier and Type | Method and Description |
---|---|
boolean |
clear(java.lang.String event)
Detach all attached
Consumers from the specified event. |
boolean |
emit(java.lang.String event)
Emit an event with the specified name.
|
boolean |
emit(java.lang.String event,
T data)
Emit an event with the specified name and data.
|
boolean |
off(java.lang.String event,
java.util.function.Consumer<T> consumer)
Detach a
Consumer from the specified event. |
boolean |
on(java.lang.String event,
java.util.function.Consumer<T> consumer)
Attach a
Consumer to the specified event. |
public final boolean emit(java.lang.String event)
event
- The name of the event to emit.Consumer
.public final boolean emit(java.lang.String event, T data)
event
- The name of the event to emit.data
- The data to pass on to Consumers
.Consumer
.public final boolean on(java.lang.String event, java.util.function.Consumer<T> consumer)
Consumer
to the specified event.event
- The name of the event to attach the Consumer
to.consumer
- The Consumer
to attach to the specified event.Consumers
attached to the
specified event.public final boolean off(java.lang.String event, java.util.function.Consumer<T> consumer)
Consumer
from the specified event.event
- The name of the event to detach the Consumer
from.consumer
- The Consumer
to detach from the specified event.Consumers
attached to the
specified event.public final boolean clear(java.lang.String event)
Consumers
from the specified event.event
- The name of the event to detach all attached
Consumers
from.Consumers
attached to the specified
event.