You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using and enjoying the csp channels, however I ran a missing function while working with a csp/mult. In clojure.core.async there is a merge function to take n channels and merge the values as they become available onto the given channel, and I think there should be an analogue for promesa.exec.csp.
Here's a rough sketch of how I'm using it:
(defnorth-xf (map (fn [[x y]] [:north x y])))
(defsouth-xf (map (fn [[x y]] [:south x y])))
;; this is the source chan, a series of [x y] coordinates
(defcoords-ch (csp/chan))
;; create a mult from the source chan
(defmx (csp/mult* coords-ch))
;; tap values from the mult into the respective work chans
(defnorth (let [ch (csp/chan:buf1:xf north-xf)]
(csp/tap! mx ch)))
(defsouth (let [ch (csp/chan:buf1:xf south-xf)]
(csp/tap! mx ch)))
;; load up the source chan with coordinates
(csp/onto-chan! coords-ch (partition-all2 (range10)))
;; this is what I want to do to consolidate all the work done:
(merge [north south])
I've come up with my own version of merge (taking inspiration from clojure.core.async) that seems to be working fine on the jvm, I haven't had to use it in CLJS yet.
I've been using and enjoying the csp channels, however I ran a missing function while working with a
csp/mult
. In clojure.core.async there is amerge
function to take n channels and merge the values as they become available onto the given channel, and I think there should be an analogue for promesa.exec.csp.Here's a rough sketch of how I'm using it:
I've come up with my own version of merge (taking inspiration from clojure.core.async) that seems to be working fine on the jvm, I haven't had to use it in CLJS yet.
I'd be happy to put together a PR for it if this is the direction you want to go.
The text was updated successfully, but these errors were encountered: