This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # beginners (114)
- # boot (10)
- # cljs-dev (18)
- # clojure (57)
- # clojure-russia (12)
- # clojure-spec (2)
- # clojure-uk (1)
- # clojurescript (62)
- # cursive (49)
- # datomic (3)
- # emacs (2)
- # mount (1)
- # off-topic (25)
- # onyx (58)
- # pedestal (5)
- # re-frame (5)
- # ring-swagger (1)
- # specter (8)
- # unrepl (2)
- # untangled (4)
- # vim (10)
- # yada (39)
When I go to compile, I'm getting an error that I have a duplicate case test constant on a line where I don't even have a
case. Here is the file in question (line 35 is where it says the error is): https://hastebin.com/ecucawobev.cljs
Here is the full error: https://hastebin.com/oliciqupaj.txt
:hooks [leiningen.cljsbuild] how to select the build id that I want to target?
I also have no idea where
'6' is coming from, since the only
case I use in the file doesn't have that :thinking_face:
I'm not using that arity now, but that was just to throw away an extra argument, if it was given
it would be nice if the compiler could give you that error directly (I bet the stack trace was created inside the unwrapping / rewriting of the form)
ah, yeah, I thought I saw something like that recently. But after looking your error message, not sure.
@lockdown- Someone was talking about that recently, I believe. You may want to check the logs. But according to Mike Fikes, it can definitely result in different JS being produced by the CLJS compiler. See here: http://blog.fikesfarm.com/posts/2015-06-15-clojurescript-case-constants.html
In CLJS, the
.- syntax gets at the value of the property on a particular object. Whereas the
. syntax invokes the method of a particular object. So,
.next might invoke the next execution of the
next method, but
.-next gets the value stored in a property called
Both dot operators are for doing host interop. On CLJS, we have both the dot operator and the dot-dash operator. On CLJ (on Java), we have only the dot operator.
So, for CLJ, yes, the dotted function syntax is for interop between CLJ and all Java libraries.
Okay, makes sense. So an r/atom has as default some property called target, which in turn has a property called value?
close, but not quite. I suppose you're talking about
(swap! bmi-data assoc param (.-target.value e))
because this is a Lisp, the first item in the list is the function operating on every other item in the list. In this case,
swap! always takes the atom it is operating on as the first argument.
in this particular example,
e is the event value that is usually passed to a callback in JS-land.
so there looking at this line, it looks like, because the second argument to
swap! is an
assoc, the value in the atom is probably a map.
swap! always supplies the value of the atom as the first argument to the function passed into
swap!s second argument.
Well actually I was talking about the component atom-input in one of the simpler examples
So we are
param as a key on the map in the atom, with the value returned by
but same deal, we are working with an
onChange listener in JS land. This always supplies an
event object to the callback being supplied. In this instance, we're using an anonymous function, so
event or what's usually called
e in many examples, is just
target there are apparently more fields we can access, one of which is called
We can see that neither of those are method invocations, because they are both dot-dash operators.
I think I get it now. So an event handler like :on-change has that implicit event, to which you can refer to with % in an anonymous function, or like
(fn [event] ...)
.- was also added to CLJ, when CLJS became popular, for cross-platform reasons. So thankfully there's no reason to write CLJ code differently. When CLJ sees
.- it treats it pretty much the same as