This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-03
Channels
- # aleph (6)
- # announcements (4)
- # babashka (73)
- # beginners (117)
- # calva (25)
- # chlorine-clover (59)
- # cider (21)
- # clara (3)
- # cljdoc (8)
- # cljs-dev (54)
- # cljsrn (15)
- # clojure (65)
- # clojure-france (5)
- # clojure-spec (3)
- # clojure-uk (13)
- # clojurescript (79)
- # conf-proposals (1)
- # conjure (17)
- # core-logic (11)
- # datomic (21)
- # fulcro (82)
- # graalvm (11)
- # helix (7)
- # jobs-discuss (11)
- # joker (2)
- # juxt (3)
- # local-first-clojure (1)
- # luminus (5)
- # nrepl (61)
- # off-topic (12)
- # pathom (70)
- # re-frame (3)
- # reitit (3)
- # rum (1)
- # shadow-cljs (58)
- # sql (1)
- # tools-deps (26)
- # xtdb (3)
Looking through the Aleph manifold API, is there an easy way to merge 2 streams? I've primarily familiar with the Rx model of streams, I know manifold has different semantics. I'd like to do a merge-map
operation, like mapcat but instead of concating the streams, it merges all returned streams together, emitting events concurrenty. Tried to create the method myself, but struggling to get a working solution.
what are the semantics of the op you want @me1260? are you wanting to merge maps from each stream or are you wanting the contents of the streams unchanged but mixed?
Ended up implementing via:
(defn merge-streams
"Takes a stream of streams, and merges them into a single stream."
[s]
(let [out (s/stream)]
(s/consume #(s/consume (fn [value] (s/put! out value)) %) s)
(s/source-only out)))
Not sure how well this compares to concat
, but the semantics are to merge each stream unchanged into the destination stream. Seems like it would be a useful operator to have in the library.
The use case is a websocket server that recieves a subscribe message, then starts streaming updates about the resource to the client. Each time a new resource is subscribed via a websocket message, I merge in a new stream of updates about the resource.
@me1260 ah, ok, you aren't doing anything with the values on the stream - in similar circumstances I've connect
ed the new streams to the merged stream