Register a handler for a specific SSE event type.
The event name to match (e.g. "message", "update").
Async function called with event data and the raw SSEEvent.
this for chaining.
Register a handler for events of a given type, automatically parsing data as JSON.
Note: JSON parse errors are silently ignored — if the event data is not valid JSON,
the handler is not called and no error is thrown. To handle parse errors, use
on() with a try/catch inside your handler.
The SSE event type to match (e.g., "update", "message").
Async function called with parsed JSON data and the raw event.
this for chaining.
Register a handler for "message" events (default event type).
Handle any event not matched by a specific handler.
Dispatch a single SSE event to the appropriate handler(s).
The parsed SSE event to dispatch.
Consume an async iterable of SSE events, routing each one.
An async iterable of SSEEvent (e.g. from SSEClient).
Route SSE events by type to registered handlers, similar to EventSource.addEventListener.