Fork me on GitHub
#hyperfiddle
<
2024-03-11
>
Tommy19:03:00

I have a missionary stream (not signal) coming from an http request, and i want to see those values in the dom/collect them my own logic. right now I have

(e/defn Response [v]
  (let [r (e/server (new (llm/ask-ant-stream v)))]
    (e/client
     (dom/h4 (dom/text r)))))
and its only rendering the very last value in the stream. When I do this, it prints the values in as they come in
(m/? (m/reduce conj (m/ap
                       (println (m/?> (ask-ant-stream "hello"))))))
any ideas? am i misunderstanding and missionary streams are treated as signals in electric? what is the best way to do what I am trying to do (show every value of stream onto dom) maybe something like
(e/client (m/? (m/ap (reset! !val (m/?> (e/server (llm/ask-ant-stream "hello")))))))

Dustin Getz20:03:37

you can use m/reductions to produce a discrete succession of accumulated values, which electric will consume as a continuous flow

Tommy21:03:03

when I do that, I still am only seeing the very last item in the stream of reductions

Tommy00:03:54

this worked, thank you

bdbrodie10:03:16

Thanks for getting this working in public, very relevant case these days.

👍 1