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> |
comment(java.lang.String comment)
Specify a comment to include as part of this event.
|
Event<T> |
data(Function<? super T,java.lang.String> function)
Sets the “data” value of the event to the return value of the given function.
|
Event<T> |
data(java.lang.String data)
Specify the event data for the server sent event.
|
Event<T> |
event(Function<? super T,java.lang.String> function)
Sets the “event” value of the event to the return value of the given function.
|
Event<T> |
event(java.lang.String event)
Specify the event type for the server sent event.
|
java.lang.String |
getComment()
The comment for this event.
|
java.lang.String |
getData()
The “data” value of the event.
|
java.lang.String |
getEvent()
The “event” value of the event.
|
java.lang.String |
getId()
The “id” value of the event.
|
T |
getItem()
The stream item that this event.
|
Event<T> |
id(Function<? super T,java.lang.String> function)
Sets the “id” value of the event to the return value of the given function.
|
Event<T> |
id(java.lang.String id)
Specify the event id for the server sent event.
|
T getItem()
java.lang.String getId()
null by default.
java.lang.String getEvent()
null by default.
java.lang.String getData()
null by default.
java.lang.String getComment()
null by default.
Event<T> id(Function<? super T,java.lang.String> function) throws java.lang.Exception
The function receives the item and is executed immediately.
The returned value must not contain a '\n' character as this is not valid in an event value.
function - a generator for the “id” value of the eventjava.lang.Exception - any thrown by functionEvent<T> id(java.lang.String id)
The value must not contain a '\n' character as this is not valid in an event value.
id - the event idEvent<T> event(Function<? super T,java.lang.String> function) throws java.lang.Exception
The function receives the item and is executed immediately.
The returned value must not contain a '\n' character as this is not valid in an event value.
function - a generator for the “event” value of the eventjava.lang.Exception - any thrown by functionEvent<T> event(java.lang.String event)
The value must not contain a '\n' character as this is not valid in an event value.
event - the event typeEvent<T> data(Function<? super T,java.lang.String> function) throws java.lang.Exception
The function receives the item and is executed immediately.
function - a generator for the “data” value of the eventjava.lang.Exception - any thrown by functionEvent<T> data(java.lang.String data)
data - the event data