public static interface ServerSentEvents.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 |
---|---|
ServerSentEvents.Event<T> |
data(Function<? super T,String> function)
Sets the “data” value of the event to the return value of the given function.
|
ServerSentEvents.Event<T> |
data(String data)
Specify the event data for the server sent event.
|
ServerSentEvents.Event<T> |
event(Function<? super T,String> function)
Sets the “event” value of the event to the return value of the given function.
|
ServerSentEvents.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
|
ServerSentEvents.Event<T> |
id(Function<? super T,String> function)
Sets the “id” value of the event to the return value of the given function.
|
ServerSentEvents.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.
ServerSentEvents.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 function
ServerSentEvents.Event<T> id(String id)
id
- the event idServerSentEvents.Event<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 function
ServerSentEvents.Event<T> event(String event)
event
- the event typeServerSentEvents.Event<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
ServerSentEvents.Event<T> data(String data)
data
- the event data