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
15
votes
3 answers

How can I create a basic ClojureScript Hello World app in Lighttable?

The documentation seems quite sparse in LightTable. I want to create a very bare bones ClojureScript web application in LightTable as a starting point to build on. I have the Instarepl in Clojure working fine, and then I create a new file called…
yazz.com
  • 57,320
  • 66
  • 234
  • 385
15
votes
1 answer

Cannot "use" in clojurescript repl

I type the following at the Clojurescript namespace. cljs.user> (use '[clojure.zip :only [insert-child]]) WARNING: Use of undeclared Var cljs.user/use at line 1 "Error evaluating:" (use (quote [clojure.zip :only [insert-child]])) :as…
Stephen Cagle
  • 14,124
  • 16
  • 55
  • 86
14
votes
2 answers

ClojureScript interop

I am trying to find out how to access Javascript objects properties in ClojureScript. If I know in advance the name of the property, that is easy. To get foo.bar I just do (.-bar foo) Is there a way to access a property whose name is known only at…
Andrea
  • 20,253
  • 23
  • 114
  • 183
13
votes
2 answers

Can't change/establish root binding of: [some-def] with set in Clojure

I could not set my dynamic var's value to new one. (def *pop* true) (set! *pop* false) => IllegalStateException Can't change/establish root binding of: *pop* with set clojure.lang.Var.set (Var.java:221) Also I've added ^:dynamic, which did not…
Ertuğrul Çetin
  • 5,131
  • 5
  • 37
  • 76
13
votes
3 answers

How do I loop through a subscribed collection in re-frame and display the data as a list-item?

Consider the following clojurescript code where the specter, reagent and re-frame frameworks are used, an external React.js grid component is used as a view component. In db.cls : (def default-db {:cats [{:id 0 :data {:text "ROOT" :test 17} :prev…
nilo de roock
  • 4,077
  • 4
  • 34
  • 62
13
votes
2 answers

if key exists: update, otherwise: assoc

consider this inside a reduce loop: (if (contains? m k) (update m k conj v) (assoc m k [v])) Is there a way to get rid of the if statement?
Anton Harald
  • 5,772
  • 4
  • 27
  • 61
13
votes
4 answers

ClojureScript - convert arbitrary JavaScript object to Clojure Script map

I am trying to convert a Javascript object to a Clojure. However, I get the following error : (js/console.log (js->clj e)) ;; has no effect (pprint (js->clj e)) ;; No protocol method IWriter.-write defined for type object: [object…
nha
  • 17,623
  • 13
  • 87
  • 133
13
votes
6 answers

js/console.log in ClojureScript

I want to implement a function with ClojureScript to simplify js/console.log like this: (defn log [& args] (apply js/console.log args)) Calling it : (log "foo" "bar") throws: TypeError: Illegal invocation but this works : (js/console.log…
HM.Yang
  • 175
  • 1
  • 2
  • 8
13
votes
1 answer

Calling JavaScript object property as a constructor from ClojureScript

I am using a JavaScript library that exposes a constructor as a property of a global object. In JavaScript, I can call the constructor like this. var thing = new Library.Thing(); How do I call the constructor in ClojureScript? None of these work. ;…
Josh Headapohl
  • 195
  • 2
  • 7
13
votes
3 answers

Check for NaN in ClojureScript

How can I check if a value is NaN? I'd prefer a solution that can be used in Clojure too without much extra stuff (so I don't want to use an external library, such as underscore). Here is what I tried (number? js/NaN) ;=> true, well I'd expect…
Adam Schmideg
  • 10,590
  • 10
  • 53
  • 83
13
votes
2 answers

How does one start programming with Clojure in Windows?

I know it is possible to use CounterClockwise inside Eclipse, but I have been trying to get Leiningen to work so that I could use ClojureScript. I downloaded leiningen using git clone. It then says run the script. I have tried lein self-install…
Bruce Whealton
  • 1,051
  • 2
  • 14
  • 25
13
votes
2 answers

Drag and drop events in embedded SVG?

Is there any possibility of receiving drag and drop events from SVG elements within a web page? I tried the Google Closure library, to no avail. Specifically, suppose my page contains
12
votes
3 answers

Clojure let allows multiple bindings with the same name

I am trying to understand some behaviour I have noticed in Clojure. It is possible to create a let binding with the same binding-name repeated multiple times: (let [a 1 a 2 a b] a) ; (= a 2) (let [a 1 a 2 a 3] a) ; (= a 3) I understand that let…
Toby Hede
  • 36,755
  • 28
  • 133
  • 162
12
votes
1 answer

What are the namespace gotchas for clojurescript when coming from clojure?

I'm trying to understand the namespacing model in clojurescript. I understand that javascript doesn't come built in with namespace support, so its been an add on via the google closure library. However, I don't understand how clojurescript deals…
bmillare
  • 4,183
  • 2
  • 23
  • 42
12
votes
2 answers

How do I create an JS Object with methods and constructor in ClojureScript

Imagine the task is to create some utility lib in clojurescript so it can be used from JS. For example, let's say I want to produce an equivalent of: var Foo = function(a, b, c){ this.a = a; this.b = b; this.c = c; } …
Lambder
  • 2,953
  • 1
  • 26
  • 20