Bustin BaseB
Denoβ€’2y 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) 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(). 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.
Was this page helpful?