Questions tagged [clojurescript]

ClojureScript is a dialect of Clojure that compiles to JavaScript.

ClojureScript is a dialect of that compiles to . ClojureScript's compiler is designed to emit JavaScript code which is compatible with the advanced compilation mode of the .

For more details, please visit the project website.

2300 questions
27
votes
3 answers

How do I create a json in clojurescript

I have some clojurescript that I want to interop with some javascript libraries. In my clojurescript code I do some analysis and come up with a list of maps. something like [{:prop1 "value1" :prop2 "value2"}, {:prop1 "something else" :prop2…
Stephen Olsen
  • 713
  • 1
  • 6
  • 14
26
votes
3 answers

What is the difference between def and defonce in Clojure?

What is the difference between def and defonce in Clojure? When to use def over defonce or vice versa?
Ertuğrul Çetin
  • 5,131
  • 5
  • 37
  • 76
25
votes
1 answer

How to access :cause, :via and :trace keys of an exception in Clojure?

I could not find a way to access :cause, :via and :trace keys of an exception. Here is the code: (try (throw (IllegalArgumentException. "1")) (catch Exception e e)) Output: #error{:cause "1", :via [{:type…
24
votes
5 answers

Is there a good ClojureScript workflow?

I'm trying to use ClojureScript for a project. To be a happy developer, I need a quick feedback-loop: write some code and see it as soon as it's possible. I'd also love to use REPL in the context of the current page. I'm using lein-cljsbuild and…
Valentin Golev
  • 9,965
  • 10
  • 60
  • 84
23
votes
5 answers

Code sharing between server and client in Clojurescript/Clojure

Say I wanted to factor out some common code between my client-side *.cljs and my server-side *.clj, e.g. various data structures and common operations, can I do that ? Does it make sense to do it ?
Hendekagon
  • 4,565
  • 2
  • 28
  • 43
23
votes
1 answer

Pretty print to a string in ClojureScript?

How does one use cljs.pprint to return a string? (cljs.pprint/pprint '(foo bar)) Would like this to return a string, rather than have a side effect of printing it. Similar to this question, but for CLJS, not CLJ. How can I pretty print a…
elliot42
  • 3,694
  • 3
  • 26
  • 27
22
votes
2 answers

Basic functionality of cljc files

Normally, Clojure source files are named (for example) foo.clj, and Clojurescript source files are named foo.cljs. My impression is that in Clojure versions >= 1.7, I can name a file foo.cljc if I want it to be available for loading with require or…
Mars
  • 8,689
  • 2
  • 42
  • 70
22
votes
2 answers

call ClojureScript from Javascript

How to call ClojureScript code from Javascript (not the other way around !). It is already possible to call Clojure from Java, but I don't know how to do the equivalent in ClojureScript.
nha
  • 17,623
  • 13
  • 87
  • 133
22
votes
4 answers
21
votes
3 answers

What do I do with ClojureScript One?

This is a wonderful project, but where to start? I thought about making my own github fork for my own project. Or making a branch for each project "inside" of it. Perhaps I do not really understand this social coding stuff yet -- but I am really…
humasect
  • 552
  • 5
  • 9
20
votes
4 answers

Why are multi-methods not working as functions for Reagent/Re-frame?

In a small app I'm building that uses Reagent and Re-frame I'm using multi-methods to dispatch which page should be shown based on a value in the app state: (defmulti pages :name) (defn main-panel [] (let [current-route (re-frame/subscribe…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
20
votes
1 answer

ClojureScript, Om and Core.async: How to handle events properly

I have had a look at using Om for rich client website design. This also is my first time using core.async. Reading the tutorial https://github.com/swannodette/om/wiki/Basic-Tutorial I have seen the usage of a core.async channel to handle the delete…
wirrbel
  • 3,173
  • 3
  • 26
  • 49
20
votes
4 answers

Is there an online tool to auto-indent and format Clojure code like there are many for JSON?

There are a lot of tools online that take a JSON text and show you formatted and well indented format of the same. Some go even further and make a nice tree-like structure: http://jsonviewer.stack.hu/ Do we have something similar for Clojure code…
Amogh Talpallikar
  • 12,084
  • 13
  • 79
  • 135
19
votes
1 answer

Clojurescript : two dots in expression

I am working with Om and I didn't fully understand the following expression : (.. e -target -checked) Here, "e" is a javascript event, and "-target -checked" is a way to access properties, if I understood well. But what about the two dots at the…
ThomasC__
  • 311
  • 3
  • 9
19
votes
3 answers

Why aren't NodeList / HtmlCollection seqable?

As a newcomer to Clojurescript it appears to me that every Clojurescript project will have some snippet of code like this: (extend-type js/NodeList ISeqable (-seq [array] (array-seq array 0))) Why isn't this part of the core library?
expez
  • 289
  • 2
  • 6