import { oak } from "https://deno.land/x/create_react_app@v0.1.2/deps.ts";
const { ServerSentEventTarget } = oak;
Dispatch a server sent event to the client. The event type
will be
sent as event:
to the client which will be raised as a MessageEvent
on the EventSource
in the client.
Any local event handlers will be dispatched to first, and if the event is cancelled, it will not be sent to the client.
import { Application, ServerSentEvent } from "https://deno.land/x/oak/mod.ts";
const app = new Application();
app.use((ctx) => {
const sse = ctx.getSSETarget();
const evt = new ServerSentEvent("ping", "hello");
sse.dispatchEvent(evt);
});
await app.listen();
Parameters
event: ServerSentEvent
Parameters
event: CloseEvent | ErrorEvent