Push live updates with Server-Sent Events
Server-Sent Events keep a single HTTP connection open, so the server can push updates whenever it wants. In Jeasx a route simply returns a standard Response wrapping a ReadableStream. When the browser goes away, the stream is cancelled and the timer is cleaned up.
The values below are pushed by the server every second and rendered by a few lines of vanilla JavaScript using EventSource.
–
–
–
Connecting...