Fork me on GitHub

@eveko For adding lein to your build config, I will defer to the more knowledgeable people here. As far as how you are designing the backend: It isn't how I would do it, but for your school project it is how it is. I'm not intimately familiar with the terminology around the Java EE world, but as long as it exposes an API to the client you shouldn’t have any problems using reagent. (And I would recommend re-frame with reagent, for at least the reason that it will make explaining the design pattern used more succinct


Hi everyone. What's a good way to do Ajax calls, and how do you do the response on the server | ring side of things?




@sova cljs-ajax + ring-defaults + buddy for auth


We're starting a clojure course at my company. We're going to start with this Clojure MOOC and then move on to clojurescript and stuff related to analytics (so Datomic, Onyx, clojure in the cloud, etc..). Anyone know any interactive clojurescript courses, similar to the one I linked? We're probably going to build our own, but inspiration is always good.


kauko: I'm also writing an interactive clojurescript book


@sova or just use Sente — it falls back to AJAX if necessary, but uses websockets by default.


How do I pass a function-reference to a macro? Context: If I hard-code ui.element.input/checkbox into my macro, I’m able to exercise that specification. But if I send it as an argument to that macro using syntax-quote, it’s not able to resolve the spec


(spec-panel `checkbox)


howdy folks! how might i go about adding the project.clj's version number as a property to my compiled javascript as part of the lein cljsbuild process?


i'm using local storage that i need to burn when a new version of the app is released


What about embedding that in the app's HTML (`<script>APP_VERSION = 1.2;<\script>`) in the backend (you can obtain the number with (some-> (io/resource "project.clj") slurp edn/read-string (nth 2))


could do, not-raspberry! thanks for the suggestion. i'm trying to avoid the need for server side code at all though.


i'm closer but i seem to have a problem with clojurescript / closure compiler, specifically closure-defines: when i try to compile my clojurescript i get the following error. it doesn't make sense to me. i'm obviously passing a string as a value to the key.

------ Figwheel Configuration Error ------

The key redgenes.core/VN at (:cljsbuild :builds :min :compiler :closure-defines) has a non-conforming value: 
  (str "some-version-number-test")
It should satisfy one of: Number | NonBlankString | boolean?

       {redgenes.core/VN (str "some-version-number-test")
        ^---- The value at key redgenes.core/VN doesn't conform


passing in a pure string works fine


@joshkh are you using Lein?


if you are everything is implicitly quoted


so you are passing a list there


i.e. ’(str “some…”)


a list containing the symbol str and a string


uhg, that's totally right. thanks dnolen. it even warned me when i quoted a key somewhere else.


everyone gets burned by this at some point 🙂


what's the fancy way of "unquoting" the form?


there’s no way to do that


if you’re using Lein you are stuck with the behavior


it’s the tradeoff of defproject being a declarative thing not a programmatic thing


gah. at the end of the day all i want is my project.clj's version somewhere within my cljs. maybe i can write a script to just append it to the compiled code, but that feels dirty.


looks like i'll be investigating boot when i find the time


someone over in #clojure linked me to this lein project and they seem to be doing it:


@joshkh cool, that’s news to me, I didn’t know defproject understood unquote


well that's the weird thing. it apparently does for them but not me. 😉


okay, just to wrap up that mystery: i had (def version "0.1") at the top of project.clj and in my cljsbuild options: ~version in an attempt to unquote it. no bueno. so then i def'ed the version in a map (def props {:version "0.1"}) and tried ~(:version props) and that worked just fine.


I'm going to replace the plain websockets in my hobby project for Sente, any reason I should not do this, or any pitfalls I might enter? The middle ware I use is compatible.


hi. I’m trying to hot-reload html imports (<link rel=”import”…) using boot-reload and not having any luck. works fine for plain old css and js, though. can figwheel or some other lib handle this?


figwheel can, not sure how, used luminus to setup my project, and it works there.


@gklijs actually I wasn’t clear enough. I’m talking about an html import that contains polymer stuff e.g.

<dom-module id="headers">
    <style> .... </style></template></dom-module>


just tried with plain old <style> as content, that didn’t work either. I’ll give figwheel a try, thanks.


@joshkh: it's not at all an elegant solution, but in the past I've used a two-step compile process on my CI server that first basically does lein pprint version, then uses sed to update a file that just has (def version "@@[email protected]@") in it, which is then followed by the normal lein cljsbuild process


Never tried the lein-unquote thing with a :closure-define, but that sounds like a better solution if you can get it working


in the end the closure-define method worked 🙂


(note that it won't work for :optimization :none)


Probably a very basic question, but how do I load an ns and then use the updated def in the same repl statement? These work consecutively but not in the same statement: works

(require '[my.ns :as mns] :reload)
=> nil
(inc mns/const)
=> 2
doesn’t work (it does not reload the ns with the new definitions)
  (require '[my.ns :as mns] :reload)
  (inc mns/const))
=> 2


out of curiosity, if you manually (inc mns/const) after the (do...) in the repl does it find const?


(i'm just wondering if it's a RACE condition)


actually that was a dumb question, sorry


Somehow the require statement is never run.


I’m solving this with a REPL action in cursive atm, but it would be neat not to have to do that


hrm, sounds like a bug


cljs probably needs to handle the gilardi scenario for that to work, like clj does


Maybe my workflow is strange, but wouldn’t this be a fairly common usecase when in the REPL? “Evaluate something, change a little code, evaluate it again"


I'm not too familiar with Cljs repls, but require will trigger async file load which needs to be finished before the code using code from required ns can be read and evaluated?


@vikeri require is a special thing, there’s no such thing as a dynamic require - it must be top level


you can’t put it inside do or anything else


@dnolen Ok, I tried using load-file as well, but it threw an error.


none of those things are going to work


so I would give it up


loads need to be top level period


Haha ok, good to know. Luckily enough Cursive solves it for me atm.


it might be possible to make it work at the REPL but it’s obnoxiously special case-y


and the fact that most editor integrations have inferior lisp like interactivity


small value add


Ok, I guess most editors have some macro (not the lisp kind) functionality and it can be solved that way if needed.


Another question, can I tell a REPL to start by evaluating a certain command? I would like my REPL to always (js/require “bootstrap.js”) the first thing it does.


at a low level yes this can be done - but other REPLs need to expose that


if you have your own REPL startup script :init is a thing


I’m using this one from the quick start:

  '[cljs.repl :as repl]
  '[cljs.repl.node :as node])

(repl/repl* (node/repl-env)
            {:output-dir "out"
             :optimizations :none
             :cache-analysis true
             :source-map true})


What is :init?


repl is just a wrapper for repl*, which takes the options as kwargs instead of a map


@juhoteperi Alright, tried updating to

  '[cljs.repl :as repl]
  '[cljs.repl.node :as node])

(repl/repl* (node/repl-env)
            {:output-dir "out"
             :optimizations :none
             :init #(js/require “./myJsFile.js”)
             :cache-analysis true
             :source-map true})
But it seems the init function is executed by Clojure? Got this erro:
Exception in thread "main" java.lang.RuntimeException: No such namespace: js, compiling:


@vikeri You could consider putting any special initialization you want into a namespace and then have it required via :repl-requires. See


Is the recommended way to make http calls using cljs?


@petr I've always just used the Xhrio utils that came with google closure (And therefore come with CLJS):




@petr I’ve recently been using this library, which is a relatively 1:1 wrapper around Xhrio ; I used to use cljs-http but found certain limitations after a while; imo it’s always better to stick to less “decorated” libraries; in the end, you can always re-create the convenience in a few lines of core.async if you need to but also retain more power/control


Hiya ClojureScripters 🙂 Would anyone have ever tried to use a polyfill so (compiled) cljs code works better on more browser? I can provide a example of a small project which currently behaves in a weird manner: I use css-transforms and clip-path, which are not properly supported on some browsers (works like a charm in Chrome Canary). Even when I try to add a polyfill from <script src=""></script> it still has a lot of issues (disclaimer: I know cljs itself doesn’t have anything to do with compatibility issue, I'm just wondering if anybody has faced such troubles)


@piotr2b are you using advanced compilation? if so, probably you have a lot of missing externs for those polyfills


Thanks for your answer 🙂 but well, I thought any JS code (as minified as possible) will always talk to standard API through their standard names, won’t they? I’ve read that relies upon user agent (so after compilation) to guess which definitions are to be sent.


@piotr2b there is no guarantee that whatever functions that service add are recognized by closure. Here is a list of stuff it knows about:


@piotr2b to work around this, you can use pass a string to aget, since that will not be renamed


Sorry @isak , I’m afraid I’m not sure to get your point: I don’t understand why I should provide externs to Google Closure. If somewhere my (not optimized) cljs code use Array.Stuff (which need to be polyfilled), will the heavily optimised js produced by Google Closure shrink this reference? I think it won’t but I’ll be happy if you prove me wrong!


hi, desperate newbie question. I want to trigger "open file dialog" on an "input type=file" element via another button's "on-click" event. I have all the elements in the dom etc. I just struggle to find the right syntax/lib to manipulate dom to trigger what would be like "$" in jquery ? I'm using re-frame


@netroms I gonna get afk from some hours but send me a msg if you still need help, it will be a pleasure to help you 🙂


thnx piotr2b, bit late here too, everything was going smooth until this problem 🙂


@isak same as above, I’m going to get afk for a couple of hours (aka night).


@piotr2b it is because you are using library functions that closure does not know about. Think about it -they aren't even in your build, they are fetched from a service. You might want to turn off advanced compilation for now, it is not something that "just works"


use -- I started using it yesterday, it's awesome