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

Which is faster, Clojure or ClojureScript (and why)?

If I had to guess, I'm pretty sure the answer is Clojure, but I'm not sure why. Logically (to me) it seems like ClojureScript should be faster: Both are "dynamic", but ClojureScript Compiles to JavaScript, running on V8 V8 engine is arguably the…
lobsterism
  • 3,469
  • 2
  • 22
  • 36
18
votes
5 answers

Idiomatically accessing json objects with clojurescript

Anyone have any docs for idiomatic clojurescript for access a javascript object (returned as json, essentially a hash)? I have a JSON object returned via an AJAX request: { list: [1,2,3,4,5], blah: "vtha", o: { answer: 42 } } How do I access…
Toby Hede
  • 36,755
  • 28
  • 133
  • 162
18
votes
3 answers

Reagent :component-did-mount

I'm trying to set the initial focus on an input element (defn initial-focus-wrapper [element] (with-meta element {:component-did-mount #(.focus (reagent/dom-node %))})) (defn chat-input [] (fn [] [initial-focus-wrapper [:input…
Brendanator
  • 833
  • 1
  • 8
  • 15
18
votes
3 answers

Client-side MVC frameworks for ClojureScript

I'm trying to choose a library for client-side MVC in ClojureScript. Here's are the ClojureScript libraries I've found so far: WebFUI (https://github.com/drcode/webfui) Enfocus: (http://ckirkendall.github.io/enfocus-site/) Pedestal…
Jonovono
  • 3,437
  • 5
  • 42
  • 64
18
votes
2 answers

What IDEs, editors and tools are available for ClojureScript development?

It has been a year since the first announcement of ClojureScript. I haven't been using ClojureScript in production, but am considering using the technology in an upcoming project. What is the current status of IDE and tooling support for…
raju-bitter
  • 8,906
  • 4
  • 42
  • 53
17
votes
3 answers

Implementing an ajax call in clojurescript

I'm new to clojurescript and would like to do a deeper dive by implementing a previously written application purely in clojurescript, but am at a loss with respect to to implement an ajax call. Can anyone point me to an example online or provide me…
Marc
  • 4,546
  • 2
  • 29
  • 45
17
votes
2 answers

How can I use Clojurescript to interact with the html DOM?

I am new to Clojurescript. I want to know how to create html elements, and how to change their properties using clojurescript. I cannot seem to find a lot of relevant information online.
mandy1339
  • 496
  • 3
  • 11
17
votes
2 answers

How do you get a timestamp in ClojureScript?

How can I get a timestamp in ClojureScript, similar to Unix's timestamp, a single number that represents the current time and date, as a number. I know that: if (!Date.now) { Date.now = function() { return new Date().getTime(); } } can be used…
yazz.com
  • 57,320
  • 66
  • 234
  • 385
16
votes
3 answers

Difference between mod and rem in Clojure

I could not understand the difference between these two (mod & rem) functions.
Ertuğrul Çetin
  • 5,131
  • 5
  • 37
  • 76
16
votes
2 answers

Reagent React Clojurescript Warning: Every element in a seq should have a unique :key

I have copied a two year old gist from here. It is now working with Figwheel and uses a more recent version of Reagent/React. I am looking for a generic way of isolating this warning message that comes to the Javascript console: Warning: Every…
Chris Murphy
  • 6,411
  • 1
  • 24
  • 42
16
votes
3 answers

ClojureScript without Java

Is it possible to compile ClojureScript without Java? I read the clojurescript nodejs quickstart but I see they still use java to compile. I checked cljs-bootstrap but they also depend on java. Is there any way to just use npm install and start…
Orlando Osorio
  • 3,116
  • 7
  • 29
  • 52
16
votes
1 answer

Why clojurescript macros can't be written in clojurescript?

While clojure and clojurescript features are basically the same (apart from obvious differences), macros are not. When I want a macro in clojurescript I have to write it in clojure and require it with require-macros. Is that a technical limitation…
islon
  • 1,166
  • 2
  • 11
  • 24
15
votes
2 answers

How To Detect "Enter" Keypress in Reagent?

Given the following code: [:input {:type "text" :value (:text @app-state) :on-change (fn [e] (if (= 31 (.-keyCode e)) (println "ENTER") (println "NOT…
Michiel de Mare
  • 41,982
  • 29
  • 103
  • 134
15
votes
1 answer

Why are clojure protocol methods often wrapped by functions?

Often when I see clojure protocols in a library, the protocol methods will be wrapped in a function, often with little added functionality. e.g.: (defprotocol Pfoo (foo-method [this])) (deftype Atype [x y] Pfoo (foo-method [this]…
Rob Lachlan
  • 14,289
  • 5
  • 49
  • 99