This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-06
Channels
- # admin-announcements (2)
- # beginners (7)
- # boot (99)
- # cider (2)
- # cljs-dev (50)
- # clojure (58)
- # clojure-austin (3)
- # clojure-australia (9)
- # clojure-berlin (8)
- # clojure-china (1)
- # clojure-dev (15)
- # clojurescript (183)
- # clojutre (2)
- # clr (1)
- # cursive (106)
- # datomic (25)
- # editors (5)
- # incanter (21)
- # ldnclj (47)
- # off-topic (11)
- # om (8)
- # overtone (5)
- # re-frame (28)
- # reagent (12)
- # testing (7)
If anyone wants informal feedback from me on an abstract for the Conj, feel free to ping me
Also, now that OS scripting is getting really close, please someone make a replacement for Ansible in ClojureScript
While migrating [garden](https://github.com/priyatam/garden/commits/master) (3000 LOC) from Cljx to Cljc, I'm stuck on few cryptic errors from cljs compiler 1.7.28. Any help appreciated!
here’s one:
Caused by: clojure.lang.ExceptionInfo: Assert failed: Argument to macroexpand must be quoted
(core/= (core/first quoted) (quote quote)) {:tag :cljs/analysis-error}
at clojure.core$ex_info.invoke(core.clj:4593)
Turns out I forgot to wrap a defmacro
defn in :clj reader literal. If only compiler error messages could point out to the source of the problem ….
@pri: patches for better .cljc
error messages welcome, hard to guess what people would encounter.
Back to the usage of cljc
reader literals: what’s the idiomatic way of adding literals in extend-protocol
(extend-protocol IExpandable
#?(:clj
clojure.lang.ISeq
(expand [this] (expand-seqs this))
clojure.lang.IPersistentVector
(expand [this] (expand-rule this))
clojure.lang.IPersistentMap
(expand [this] (list (expand-declaration this)))
Object
(expand [this] (list this))
:cljs
IndexedSeq
(expand [this] (expand-seqs this))
PersistentArrayMap
(expand [this] (list (expand-declaration this)))
PersistentHashMap
(expand [this] (list (expand-declaration this)))
PersistentTreeMap
(expand [this] (list (expand-declaration this)))
default
(expand [this] (list this)))
CSSFunction
(expand [this] (list this))
CSSAtRule
(expand [this] (expand-at-rule this))
CSSColor
(expand [this] (list this))
nil
(expand [this] nil))
error:
clojure.lang.ExceptionInfo: Feature should be a keyword: (expand [this] (expand-seqs this)) {:type :reader-exception, :line 274, :column 41, :file “/~/garden/src/garden/compiler.cljc"}
The cljx syntax [was simpler](https://github.com/noprompt/garden/blob/master/src/cljx/garden/compiler.cljx#L270)
The only way I can get this to eval is to create separate :clj
and :cljs
protocols and repeat the common elements in each. I’m sure there’s a better way ...
you also have #?@ for splicing but you can’t do that at the top level, but doesn’t really matter much IMO
I still get the error Feature should be a keyword: (render-css [this] (map render-css this))
For simpler forms it’s easy, but I’m struggling with code that has protocols or defrecords implementing protocols
but with extend-protocol
, I’m dealing with multiple forms at each protocol level. Should I just wrap each and every protocol/impl? https://github.com/noprompt/garden/blob/master/src/cljx/garden/compiler.cljx#L270
@pri: step back - I cannot see what problem you are trying to solve that I did not already answer
you can A) use two separate reader conditional expressions B) use reader conditional splicing
Hi, i'm trying to use reagent/set-state, but it seems that all my instance of the same component recieve the same reageant/set-state when i change it on only one of them
I've stored this current component on a let binding at the beging of my reagent component function
So two questions, could we use reageant/set-state with reageant/hipcup plain function ?
If interested in getting hands dirty with Planck dev, I’ve started marking “newbie” issues: https://github.com/mfikes/planck/issues?q=is%3Aopen+is%3Aissue+label%3Anewbie
Hi, is using cljs.build.api in custom scripts now recommended over lein-cljsbuild? I got the impression that's the currently recommended practice. For example, the Clojurescript wiki doesn't recommend starting with lein-cljsbuild (https://github.com/clojure/clojurescript/wiki/lein-cljsbuild).
I discovered this function by accident: is it intended for public use, if so, in what cases would one use it? https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L9935
@borkdude: Hah, I was wondering the same when I noticed that Planck auto completes it for te
@jindrichm: that’s not what that page says, it’s not a recommended starting point
lein, boot, Maven, or nothing else at all are perfectly fine ways to work with ClojureScript
bit of self-promotion - I wrote a Chrome extension in Clojurescript to help with code review on GitHub - https://github.com/smcgivern/gitique
and I very much like the usability of the build scripts, no lein or boot here, much less to think about when getting started
@dnolen: You're right. Do I read that correctly that recommended starting point is to use custom scripts using cljs.build.api?
@dnolen: Is it favoured as a starting point because it doesn't hide the complexity of the build process as lein-cljsbuild does?
@jindrichm: build scripts aren’t any more complicated then lein-cljsbuild
what it does is show you how it actually works so you can diagnose the issues 3rd party tooling tends to introduce
another newbie friendly JIRA issue http://dev.clojure.org/jira/browse/CLJS-1393
wow https://github.com/clojure/clojurescript/commit/139da195125110646f8d5550fc753fdbf63f565c
but the above means for Cursive users and non-Cursive users you can get decent debugging of ClojureScript on Node
(it predates the commit, so if it's bad and it works it can't be that bad, but I've never seen that before)
Anyone else getting SyntaxError: Unexpected token ;
when doing (declare x)
?
Only getting it when calling declare
with a single arg, works with 2+.
@martinklepsch: I suspect this is a REPL specific issue around :def-emits-var
, \cc @mfikes
@teslanick: I wouldn’t blindly copy any idiom you find in the ClojureScript compiler
uh, interesting, thanks!
@martinklepsch: Turn on :repl-verbose
and you’ll see why.
@martinklepsch: I take that back… I think you need to actually debug things to see why. But in short it becomes a NOOP which fails for the JS emitted at the REPL. I think this has been the case for at least a year.
@mfikes: "Error evaluating:" (declare test-var) :as “”
this made me understand
declare only modifies the compiler env but doesn’t actually emit anything
@martinklepsch: Here is the JavaScript sent to the engine for (declare test-var)
:
javascript
(function (){try{return cljs.core.pr_str.call(null,(function (){var ret__4371__auto__ = ;
cljs.core._STAR_3 = cljs.core._STAR_2;
cljs.core._STAR_2 = cljs.core._STAR_1;
cljs.core._STAR_1 = ret__4371__auto__;
return ret__4371__auto__;
})());
}catch (e7994){var e__4372__auto__ = e7994;
cljs.core._STAR_e = e__4372__auto__;
throw e__4372__auto__;
}})()
So it has to do with the REPL’s “wrapping” JavaScript to instrument *1
and *e
resulting in the derailment.
@martinklepsch: You can work around it (and cause the compiler analysis metadata to be updated) by doing something like this (do (declare test-var) nil)
@mfikes: thanks that’s very handy!
It could probably be fixed in cljs.repl
or in the compiler (which would be nicer for the case when :def-emits-var
is enabled and you are doing something like (def x)
), the challenge being perhaps knowing when to do it.
@mfikes: I’m currently trying to figure out if I can declare
something with metadata but it seems not possible, is that correct?
@martinklepsch: To be honest, for something like that, I’d fire up lein repl
and see how Clojure behaves.
@martinklepsch: And if you find something that works in Clojure but not ClojureScript. Don’t give up. (http://dev.clojure.org/jira/browse/CLJS-1333 for example)
Well it seems to work in none of them 😛
boot.user=> (declare ^{:w true} test-var)
#'boot.user/test-var
boot.user=> (meta test-var)
nil
@martinklepsch: Meta is on the var
user=> (declare ^{:w true} test-var)
#'user/test-var
user=> (meta #'test-var)
{:ns #<Namespace user>, :name test-var, :w true, :file "NO_SOURCE_PATH", :column 1, :line 1, :declared true}
@martinklepsch: That works in Planck
@martinklepsch: And in Ambly. So it works in ClojureScript and bootstrapped ClojureScript.
ugh, I’m so stupid 😄
@martinklepsch: No… you can have meta on collection values as well. Probably not what you meant but, nevertheless:
user=> (def x ^{:w true} [1])
#'user/x
user=> (meta x)
{:w true}
yeah, that makes sense. Thanks!
I'm trying to use the Google Maps Place Search API
I can successfully add a map (with the help of the reagent cookbook), and I feel like I'm really close with the Place Search
Just, you know, not quite there.
@martinklepsch: I’ll be putting together a patch for http://dev.clojure.org/jira/browse/CLJS-1397
When I try to implement
service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
It fails with the error null has no properties
Function looks like:
(defn get-places []
(let [lat 56.325760
lng 44.004964
center (google.maps.LatLng. lat, lng)
map-opts (clj->js {:center center
:zoom 12})
map-canvas (.getElementById js/document "map-canvas")
mappy (js/google.maps.Map. map-canvas map-opts)
request (clj->js {:location center :radius 10000 :types "['store']"})]
(.nearbySearch (google.maps.places.PlacesService mappy) request
(js/console.log (pr-str)))))
I'm expecting to get back an array.
Does anything seem obviously wrong with this?
@coyotespike: one thing that may be affecting it is that you're just calling google.maps.places.PlacesService
but in the js example you showed there is a new
which you don't seem to take into account
I am trying to use transit & cljs-ajax together, but i can't seem to read the json response correctly:
(def reader (t/reader :json))
(defn render-app [resp]
(println (t/read reader resp))
(q/render (App) (.getElementById js/document "app")))
(GET "" {:handler render-app})
@coyotespike: and another thing - your callback is missing a #
to make it into a function. (js/console.log (pr-str))
isn't a function
I get an Unexpected end of input and an Unexpected string
@coyotespike: and not sure what you're doing with pr-str there
@jeremyraines: more information - what does resp
print as before attempting to read it
@coyotespike: and, the api docs say that the request "types" option should be an array but yours is a string
@antishok: thanks for the suggestions!
I changed to #(js/console.log), and also tried using a plain array.
[{name Pants, id 1339254, color_name Dark Gray, keywords joseph other pants joseph farfetchcom dark gray pants other pants female, large_default_image_url {name Bag, . . .
Even that change isn't working
oh, I get it I think. cljs-ajax is already converting it to a clojure vector
I believe you initialize a new google.maps.placesService
object by calling it, or assigning to a variable. The new
isn't necessary.
I have a function that looks pretty similar, but just makes the map, and a marker on the map.
and that works...
@coyotespike: from a simple test i'm doing (in javascript) the new
is needed
@antishok: yes, but not when it's translated into ClojureScript
did you get it to work in js?
@jeremyraines: yeah doesn’t look like JSON to me
not sure what you mean not when it's translated to cljs? in cljs you need to just add the dot, no?
@coyotespike: i just got this working in js, not really familiar with the api. http://jsfiddle.net/6aucyony/1/
oh, cool
Also, if you look at the translation here: https://github.com/reagent-project/reagent-cookbook/tree/master/recipes/google-maps
you can see how they "translate" to CLJS
so in your code (google.maps.places.PlacesService mappy)
should be (google.maps.places.PlacesService. mappy)
lol I was just typing in that I tried that and that error is gone!
That is pretty exciting
Thanks for helping me sort through that, I'd been stuck a lot longer
Yeah, I'm so bad at it, but slowly getting better