This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-10
Channels
- # announcements (3)
- # architecture (54)
- # babashka (11)
- # beginners (12)
- # calva (5)
- # clj-on-windows (1)
- # cljdoc (2)
- # cljs-dev (1)
- # cljsrn (6)
- # clojure (130)
- # clojure-europe (8)
- # clojurescript (21)
- # conjure (23)
- # core-async (4)
- # datomic (7)
- # depstar (77)
- # events (1)
- # fulcro (27)
- # lsp (88)
- # malli (5)
- # meander (1)
- # off-topic (4)
- # pathom (43)
- # polylith (39)
- # re-frame (9)
- # shadow-cljs (14)
- # timbre (3)
- # tools-deps (53)
This may be more of a macro expansion question than async, but i'm noodling on how to express channels WRT alt!!
; Works as expected
(let [c1 (async/chan 1)
c2 (async/chan 1)
t (async/timeout 1000)]
(async/>!! c2 :message-2)
(async/alt!!
t :timed-out
[c1 c2] ([v p] (str "Read " v " from " p))
:default :no-action))
; fails. the vector of ports for alt!! is pre-bound.
(let [c1 (async/chan 1)
c2 (async/chan 1)
chans [c1 c2]
t (async/timeout 1000)]
(async/>!! c2 :message-2)
(async/alt!!
t :timed-out
chans ([v p] (str "Read " v " from " p))
:default :no-action))
in my case, i have a generic operation function that takes 2 optional maps - read operations and write operations. I would like to be able to concat these together and provide them as vector to alt!! but am hitting the above snag.
What's the error that you're getting? If you can't do the top version, then you may have to use alts!!
and manually react to which channel operation succeeded
Thank you. alts!! resolved it