Fork me on GitHub

Trying to wrap my head around using core.async in clojurescript to get around an ajax callback in a reagent template, any advice on places to look?


There are channels for #reagent #clojurescript and #core-async that might be able to help (but things tend to be pretty quiet on a Sunday)


ok, cool, I think I may have figured out what I needed for now, but I'll keep those in mind the next time I have questions


Hey everyone, is there a canonical formatting and or linting used in the clojure{script} world? I have done a lot of Golang, and in Go, formatting and basic linting is provided by the complier, which silences all the arguments. I'd love to just use the "generally accepted" formatting and linting right off the bat


I can recommend clj-kondo as a “generally accepted” linter, and this blog post about formatting will explain why there is no such tool (at least not “generally accepted” 🙂 ) -


Ok, thanks @U04V4KLKC thats very helpful


Hi, I need a hand with interop... In Java I have following scenario: I have a builder with a bunch of methods on it. It has signatures with varargs and there are also overrides like this:

Builder someAction(String s, Operation... ops);
Builder someAction(Pattern p, Operation... ops);
I didn't find a way to call any of these from Clojure. Is there a way how to hint types in such case? Operation[] hint would be handful, but I don't know how to declare it.


Use (into-array Operation [ ...operation instances... ])


🆒 into-array was exactly what I was looking for 🙂 I tried make-array and object-array but it's clearly wrong because target type is then Object[] Thanks Alex! It would be great if there is an example in the faq page below.


sounds like a good idea



👍 1
💯 1

(.someAction builder "foo" (into-array Operation [])) - like that

Ramon Rios16:12:52

Is there a way for execute two side effects on a function?


(defn effects [] (fire-missiles) (delete-all-users) (utter-chaos!))


not sure what you're looking for but you can use a do expression. And defn's have an implicit do body

Ramon Rios17:12:50

I would like to have to call two assoc-in in a function

Ramon Rios17:12:56

To set 2 different values

Ramon Rios17:12:25

I'm asking it cause in my lein midje autotest i see that it's only recognizing the last assoc on the function that i'm calling


if you have something like this

(let [foo {:a 1}]
  (assoc foo :b :2)
  (assoc foo :c 3))
you aren't changing foo but making a new value. So the first assoc call creates a map with the b key on it but that doesn't change foo.
(let [foo {:a 1}]
  (-> foo
      (assoc :b :2)
      (assoc :c 3)))
Compare that to this threaded version


exactly. this is saying "take foo, make a copy of it with the b key as two, and then to that copy put the c key.

Ramon Rios17:12:18

This is a macro, right?

Ramon Rios17:12:09

I saw it a lot on java or other functional stuff, but the concept of this and ->> doens't fit on my mind


yes its a macro


and a quite popular one in clojure


which is equivalent to (assoc (assoc {:a 1} :b 2) :c 3)

Ramon Rios17:12:54

(defn check-correspondence [db]
  (assoc-in db [::current :policy-correspondence] :prod-manager)
  (assoc-in db [::current :invoicing-correspondence] :prod-manager))

Ramon Rios17:12:05

That´s my code


yup. common mistake. Clojure's data structures are immutable. So in your first assoc-in call you don't keep that value so it is effectively thrown away


Read you statements as "to a copy of db, add the prod-manager under policy-correspondence. to a different copy of db, add prod-manager at invoicing-correspondence"

Ramon Rios17:12:55

I think now it's main main challange, to refactor my way of think for functional and immutable data

Ramon Rios17:12:19

And how should be the right way for do it?


try those two different forms i put above in a repl


Can we yield a map from an anonymous function? Something like this? #({:document %}) What would be the correct syntax?


(#(do {:a %}) 1) but the syntax doesn't buy anything over ((fn [x] {:a x}) 1) in my opinion


Thanks you for confirming my suspicion. Yeah, it does not buy anything. fn it is.

👍 1

#(hash-map :a %) is another option

👍 1

Sorry to cut you off @ramon.rios @dpsutton. Did not notice you were in a conversation.


we should have threaded. that's just kinda the way channels works. no reason to apologize 🙂

👍 1

but nice of you to think that 🙂

Ramon Rios17:12:41

No problem @hindol.adhya 🙂 . We should had opened a thread for that

👍 1
Ramon Rios18:12:24

Is there some way of use a !false in clojure?

Ramon Rios18:12:28

For example. i want to check a value with contains? but actually, i would like to check if this value not exist in the map

Ramon Rios18:12:58

like a not-contains?


See in clojure.core: 1. not 2. if-not 3. when-not 4. complement 5. not=


Also, if you are filtering a sequence, remove is a drop in replacement that does the opposite. Filter preserves the matches, remove drops them.

Enyert Vinas18:12:26

for example you can use this (not (contains? coll key))