This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-19
Channels
- # announcements (3)
- # beginners (29)
- # biff (10)
- # calva (33)
- # cider (1)
- # clara (8)
- # clerk (10)
- # clj-kondo (6)
- # cljs-dev (5)
- # clojure (40)
- # clojure-dev (3)
- # clojure-europe (43)
- # clojure-gamedev (1)
- # clojure-nl (1)
- # clojure-norway (19)
- # clojure-uk (2)
- # clr (3)
- # cursive (12)
- # datomic (4)
- # devcards (3)
- # gratitude (3)
- # honeysql (13)
- # hoplon (25)
- # humbleui (3)
- # hyperfiddle (38)
- # malli (26)
- # pathom (38)
- # practicalli (2)
- # rdf (6)
- # reagent (8)
- # shadow-cljs (13)
- # xtdb (1)
are there any good libraries or examples out there for fetching and displaying event streams in clojurescript/reagent/re-frame?
I don't think there's enough details in the question to provide a useful answer. What is an "event" exactly? What is a "stream"? How does one fetch a stream? What would be an appropriate way of rendering a fetched event stream?
For example, it's easy to imagine that you have a WebSocket connection where a stream of events is just serialized EDN data that you receive as text messages.
In that case, you can have e.g. an instance of PersistentQueue
in an atom storing a window of the latest 1000 messages that you display as strings without deserialization in a flat list with Reagent while using a message's timestamp as the item's key.
specifically SSE https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events
was curious if there are any examples out there, for someone who has not worked with anything like this before (easy is relative heh)
I've just used EventSource
directly. The whole connection handling is like 15 lines and then you can just dispatch the received events to re-frame and handle everything else like regular.
that makes sense! my use case was unusual (didn't know it at first) in that i wanted to use a POST endpoint, and EventSource is only meant for GET. i ended up finding the sse.js
library which solves that, and was able to use it with shadow cljs.
this is what i ended up with for a simple openai chat interface: https://gist.github.com/eemshi/81beda81558a0bb480ee0f5221b93519