This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-07
Channels
- # adventofcode (62)
- # babashka (88)
- # beginners (52)
- # boot (2)
- # bristol-clojurians (1)
- # calva (7)
- # cider (16)
- # circleci (4)
- # clj-kondo (12)
- # cljdoc (5)
- # cljsrn (4)
- # clojure (53)
- # clojure-dev (1)
- # clojure-spec (7)
- # clojure-uk (7)
- # clojurescript (25)
- # core-async (14)
- # duct (1)
- # emacs (10)
- # figwheel-main (3)
- # fulcro (11)
- # garden (14)
- # jobs (1)
- # klipse (2)
- # luminus (1)
- # malli (9)
- # re-frame (6)
- # reagent (13)
- # remote-jobs (1)
- # shadow-cljs (124)
- # sql (1)
- # testing (15)
- # tools-deps (13)
- # uncomplicate (1)
- # vim (1)
Hi all
Question xpost from #clojure:
(require '[clojure.core.async :as async :refer [go-loop chan >! <!! close!]]
(defn tst [out]
(go-loop [[x & xs] (range 5)]
(when (seq xs)
(println "now here:" x)
(>! out x)
(recur xs))))
Why does this:
(def out (chan 2000))
(tst out)
(close! out)
(println "value here: " (<!! (async/into [] out)))
Print:
> now here: 0
> now here: 1
> now here: 2
> now here: 3
> value here: [0 1 2 3]
And this:
(let [out (chan 2000)]
(tst out)
(close! out)
(println "value here: " (<!! (async/into [] out))))
Print:
> now here: 0
> value here: now here:[ ]1
> now here: 2
> now here: 3
Why does putting it in a let block lead to async output?
And not return the full vector of values?My goal is to have a function that uses channels but returns a value (not a channel);
Hmm when I debug and halt on every step it does return properly
I thinkt here’s a timing issue
Channel closed before program is finished or something
Values are not yet delivered, but I already read them via async/into
I see i had to wait before reading
E.g., (<!! (async/timeout 100))
I don't think that's a robust solution because the rate with which you generate the number could change.
Hi. I am stuck with using core.async in AWS Lambda handler in Clojurescript. The Lambda handler invokes the callback function, and returns as lambda function's result. The issue I am having is how to return a value when reading a channel, eg outside of a go
block. take!
just returns nil, while (go ..)
block returns yet another channel.
(defn handlerfunc [event context callback]
(go
(callback nil (clj->js {:body (str (<! ch))}) )))
In this example I am stuck with the channel while I need the value of (<! ch)
The handlerfunc needs to have a value returned by the last statement. Printing doesn't help, obviously, and there are no blocking <!! macros in CLJS.