Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/sse.ts

A JavaScript extension package for building strong and modern applications.
Latest
import * as ayonliJsext from "https://deno.land/x/ayonli_jsext@v0.9.72/sse.ts";

This module provides tools for working with server-sent events.

The EventEndpoint is used to handle SSE requests on the server and send messages to the client, while the EventSource and the EventConsumer are used to read and process messages sent by the server.

Despite their names, these classes can be used in both the browser/client and the server environments.

NOTE: This module depends on the Fetch API and Web Streams API, in Node.js, it requires Node.js v18.0 or above.

Classes

Unlike the EventSource API, which takes a URL and only supports GET request, the EventConsumer API accepts a Response object and reads the messages from its body, the response can be generated from any type of request, usually returned from the fetch function.

An SSE (server-sent events) implementation that can be used to send messages to the client. This implementation is based on the EventTarget interface and conforms the web standard.

This is an implementation of the EventSource API that serves as a polyfill in environments that do not have native support, such as Node.js.

Variables

v
EventClient
deprecated
v
SSE
deprecated

Interfaces

The options for the EventEndpoint constructor.