public interface IReactiveSSEDataDriverContextVariable extends IReactiveDataDriverContextVariable
Interface to be implemented by context variables wrapping asynchronous objects in the form of reactive data streams which are meant to drive the reactive-friendly execution of a template in SSE (Server-Sent Event) mode.
   This interface adds to IReactiveDataDriverContextVariable the possibility to specify the first ID value
   to be used for generating SSE events. This is useful in SSE scenarios in which the browser requests the server
   to reconnect after a connection failure, specifying the HTTP Last-Event-ID header so that the
   application can start generating events again starting from the event following the last one successfully
   processed by the browser.
 
Returning SSE (Server-Sent Events) through Thymeleaf requires the presence of a variable implementing this interface in the context. Thymeleaf will generate three types of events during rendering:
   Note that in the case of SSE, the value assigned to the IReactiveDataDriverContextVariable.getBufferSizeElements() property can actually
   affect the immediacy of the generated (published) events being sent to the browser. If this buffer is set e.g.
   to 4, only when a total of 4 items of data are generated will be sent to the browser as SSE events.
 
   The ReactiveDataDriverContextVariable class contains a sensible implementation of this interface,
   directly usable in most scenarios. Example use:
 
 @RequestMapping("/something")
 public String doSomething(final Model model) {
     final Publisher<Item> data = ...; // This has to be MULTI-VALUED (e.g. Flux)
     model.addAttribute("data", new ReactiveDataDriverContextVariable(data, 100, 1L)); // firstEventID = 1L
     return "view";
 }
 | Modifier and Type | Method and Description | 
|---|---|
long | 
getFirstEventID()
   Returns the first value to be used as an id in the case this response is rendered as SSE
   (Server-Sent Events) with content type text/event-stream. 
 | 
getBufferSizeElements, getDataStreamlong getFirstEventID()
Returns the first value to be used as an id in the case this response is rendered as SSE (Server-Sent Events) with content type text/event-stream.
After the first generated events, subsequent ones will be assigned an id by incrementing this first value.
Copyright © 2017 The THYMELEAF team. All rights reserved.