DenoDDeno
Powered by
Bustin BaseB
Denoβ€’3y agoβ€’
4 replies
Bustin Base

How can I do server sent events on the client side in deno?

I have a server api which is doing server sent events correctly, I can see it in curl doing what I would expect.

One the calling side I have a simple cli written in deno and I'm trying to use an EventSource, which is not a requirement. If there is an easier way I'm all for it. The downside of the EventSource is that it is an event handler api, where you subscribe to
on('message', handler)
on('message', handler)
and I'm looking for an async generator api. If I just use the EventSource as is, it appears to not work at all, the process just exits right away as if its not taking out a
ref()
ref()
. If I convert it into an async generator then I"m getting a "Top-level await promise never resolved" error.

I'm wondering if anyone has any simple examples of doing server sent events in deno client side? Using EventSource is not required at all.
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Server Sent Events with Fresh
notiggsamNnotiggsam / help
3y ago
How can I make sure the code gets run on the client-side??!
wedmaniacWwedmaniac / help
3y ago
how do I access post data in a deno http server?
InkeIInke / help
13mo ago