This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-17
Channels
- # bangalore-clj (2)
- # beginners (202)
- # boot (18)
- # cljs-dev (8)
- # cljsjs (7)
- # cljsrn (4)
- # clojars (2)
- # clojure (401)
- # clojure-boston (2)
- # clojure-dusseldorf (1)
- # clojure-gamedev (36)
- # clojure-greece (2)
- # clojure-italy (1)
- # clojure-russia (16)
- # clojure-spec (27)
- # clojure-uk (7)
- # clojurescript (68)
- # core-async (16)
- # cursive (25)
- # datascript (1)
- # datomic (34)
- # funcool (1)
- # hoplon (1)
- # interop (1)
- # klipse (1)
- # leiningen (2)
- # lumo (75)
- # off-topic (17)
- # om-next (2)
- # onyx (66)
- # re-frame (18)
- # reagent (2)
- # ring-swagger (11)
- # spacemacs (1)
- # specter (1)
- # timbre (3)
- # untangled (48)
- # yada (7)
what would be the idiomatic approach to block the current thread until a certain message is received from a core.async channel ? i would be err’ing towards a semaphore-like approach with a promise/future, but i was wondering whether there is a proper core.async facility for this…
Or a promise + take! that delivers the value + deref on promise, which is almost the source of <!!
@lmergen By "a certain message" you mean other messages may arrive before the one you are waiting for?
for context, i’m using the kinsky
kafka library, which has a control channel that emits errors, or, an eof
message in case the connection was closed
so my current solution involves a poller go-loop that loops until the eof
arrives, and then fulfills a promise
Sounds like a good solution to me. You could alternatively pipe the control channel into another channel with a corresponding filter
transducer and wait for that via <!!
instead of derefing a promise. But I wouldn't say that's strictly more idiomatic...
Actually, you don't even need the promise, just <!!
on the channel returned by your go-loop
(that's referring to your current solution)