T - the item type contained in the eventpublic interface Event<T>
The item is the item in the data stream being emitted as a server sent event.
It can be used to derive values for the id(ratpack.func.Function<? super T, java.lang.String>), event(ratpack.func.Function<? super T, java.lang.String>) and/or data(ratpack.func.Function<? super T, java.lang.String>) fields.
By default, the id, event and data fields are set to null.
| Modifier and Type | Method and Description |
|---|---|
Event<T> |
data(Function<? super T,String> function)
Sets the “data” value of the event to the return value of the given function.
|
Event<T> |
data(String data)
Specify the event data for the server sent event.
|
Event<T> |
event(Function<? super T,String> function)
Sets the “event” value of the event to the return value of the given function.
|
Event<T> |
event(String event)
Specify the event type for the server sent event.
|
String |
getData()
The “data” value of the event.
|
String |
getEvent()
The “event” value of the event.
|
String |
getId()
The “id” value of the event.
|
T |
getItem()
The stream item that this event.
|
Event<T> |
id(Function<? super T,String> function)
Sets the “id” value of the event to the return value of the given function.
|
Event<T> |
id(String id)
Specify the event id for the server sent event.
|
T getItem()
String getId()
null by default.
String getEvent()
null by default.
String getData()
null by default.
Event<T> id(Function<? super T,String> function) throws Exception
The function receives the item and is executed immediately.
function - a generator for the “id” value of the eventException - any thrown by functionEvent<T> id(String id)
id - the event idEvent<T> event(Function<? super T,String> function) throws Exception
The function receives the item and is executed immediately.
function - a generator for the “event” value of the eventException - any thrown by functionEvent<T> event(String event)
event - the event typeEvent<T> data(Function<? super T,String> function) throws Exception
The function receives the item and is executed immediately.
function - a generator for the “data” value of the eventException - any thrown by function