Fork me on GitHub
#clojurescript
<
2016-09-11
>
jasonjckn00:09:45

it is possible to iterate through a namespace in cljs at runtime?

jasonjckn00:09:21

see all the difference vars belonging to that namespace

yury.solovyov10:09:23

where core.async <? macro is located?

yury.solovyov10:09:46

nevermind, it is a custom one

darwin11:09:49

@jasonjckn not really at runtime, but you can extract this information at compile-time, encode it into your own data structure and emit it into generated javascript code as cljs data

yury.solovyov12:09:27

how do I organize multiple async operations via core.async with limited concurrency? have 1 buffered channel and multiple readers?

yury.solovyov12:09:21

by concurrency I mean multiple go blocks or something like that, not real threads ofc

artur13:09:24

If I have a function: (def ^:private render-row [label data key] [:p label (:key data) ]) How can I access data dynamically by the name of the key given in parameter "key"?

anmonteiro13:09:30

@artur (get data key)?

anmonteiro13:09:29

Also, PersistentMaps also implement IFn so you can do (data key) as well

yury.solovyov13:09:19

can I put value on a channel that is read from another channel? like (>! chan (<! (stat-file item)))

gtrak14:09:31

@yury.solovyov yes, inside a go block, you can do any combination of channel ops that will park/yield to/from any channels. Some of the built-in core.async public functions are just wrappers over go/go-loop.

yury.solovyov14:09:11

what about my earlier question?

yury.solovyov14:09:25

any suggestions?

gtrak14:09:01

I'm not sure what kind of answer you're looking for, but in general I write channel-returning functions and compose them with higher-level go-blocks.

gtrak14:09:16

if you have multiple channels, your choices of what to do with them might include something like alts or mux or pipeline, or something more manual with a go-block.

gtrak14:09:52

A higher-level org-structure might include the 'component' library to wire things up, and an example is detailed here: http://matthiasnehlsen.com/blog/2014/09/24/Building-Systems-in-Clojure-1/

yury.solovyov15:09:33

what kind of looping can I use inside go block? can I use doseq ?

wilkerlucio15:09:47

@yury.solovyov you should be able to use most of the things, just be careful about inner functions, they are considered a different scope

wilkerlucio15:09:06

and yes, you can use doseq

yury.solovyov15:09:13

though stats are performed ok

anmonteiro15:09:59

@yury.solovyov pretty sure your problem is in L42 of the gist

anmonteiro15:09:15

into’s 2nd arg should be a sequence

anmonteiro15:09:29

but you’re just taking 1 item from the channel and passing that

yury.solovyov15:09:39

I guess its different into

yury.solovyov15:09:56

and I'm using collection into...

anmonteiro15:09:19

@yury.solovyov right so maybe you should probably use the core.async/into

anmonteiro15:09:43

you’re definitely using cljs.core/into

anmonteiro15:09:29

(you should also close the channel whenever doseq is finished for into to return)

yury.solovyov15:09:08

(<! (into (vector) (<! (map-items-to-stats res))))

yury.solovyov15:09:28

needed to extract value from into, cause it is channel too