sse
Server-sent events endpoint that pushes reload pings to connected browser tabs.
fn events
pub async fn events(
State(state): State<AppState>,
) -> Sse<impl tokio_stream::Stream<Item = Result<Event, Infallible>>>SSE endpoint that streams named ping events to connected clients.
Each item from the state’s broadcast channel, including a lag notice, becomes one ping event with the data
reload; the stream also sends keep-alive comments.
| Parameter | Type | Description |
|---|---|---|
State(state) |
State<AppState> | the shared state, whose reload channel the stream subscribes to |
| returns | Sse<impl tokio_stream::Stream<Item = Result<Event, Infallible>>> | The event stream for /events. |