What to notice
Server-Sent Events are useful when the browser only needs data pushed from the server. They are simpler than WebSockets for one-way streaming because the browser keeps a regular HTTP connection open and receives text-based event frames.
In this example, the route sends a named connected event once and a tick event every 2 seconds. The client subscribes with EventSource and updates the UI as each event arrives.