This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-02
Channels
- # beginners (26)
- # bitcoin (1)
- # boot (9)
- # boot-dev (5)
- # cider (26)
- # cljs-dev (1)
- # clojure (190)
- # clojure-finland (1)
- # clojure-italy (42)
- # clojure-nl (20)
- # clojure-russia (3)
- # clojure-sanfrancisco (1)
- # clojure-serbia (1)
- # clojure-spec (50)
- # clojure-uk (16)
- # clojurescript (62)
- # core-async (4)
- # cryogen (1)
- # cursive (6)
- # datascript (1)
- # datomic (36)
- # duct (6)
- # editors (6)
- # emacs (14)
- # graphql (3)
- # leiningen (30)
- # off-topic (21)
- # om (7)
- # parinfer (13)
- # portkey (56)
- # re-frame (2)
- # reagent (2)
- # shadow-cljs (58)
- # vim (1)
- # yada (3)
@lxsameer or if you use put! make sure you also use a callback that limits how soon you call put! again. That's really the key here, put! requires manual implementation of backpressure
Sometimes that's easy (like when dealing with a async message queue), sometimes it's harder
A go-loop
that pipes from in
to out
is really nothing more than this:
(defn pipe [in out]
(take! in
(fn [val]
(when val
(put! out
(fn [put?}
(when put?
(pipe in out))))))))
That handles back pressure just fine, but as you can see it's a bit more ugly than:
(defn pipe [in out
(go-loop []
(when-some [val (<! in)]
(when (>! out val)
(recur)))))
@tbaldridge thanks man