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
1
vote
2 answers

Lein Figwheel Compile Error

I've been with figwheel for most of the day, then suddenly after a restart (not the first) it started to fail to compile. I get the following message when I run lein figwheel. Figwheel: Starting server at http://localhost:3449 Figwheel: Watching…
Dan Prince
  • 29,491
  • 13
  • 89
  • 120
1
vote
2 answers

Iterated Callback Hell (in ClojureScript)

1 The Problematic JavaScript Function I am dealing with a very problematic function in JS that invokes a callback function an iterated number of times. In particular, the function takes a yaml string and runs a callback function for each number of…
George
  • 6,927
  • 4
  • 34
  • 67
1
vote
1 answer

js object to clojurescript vector/map

Through a Jsonp call I fetch some (json) data from a remote api, response: #js [#js {:id 1501} #js {:id 1502}] How do I turn them into a clojurescript vector with maps inside? i.e. [ {:id 1501} {:id 1502} ]
Seneca
  • 2,392
  • 2
  • 18
  • 33
1
vote
1 answer

ClojureScript (nodejs) function that returns the string content of a file

I am trying to make a function that takes a file path and returns its content as a string. Here is my code snippet: (defn get-string-from-file-path [path] (let [fs (node/require "fs") c (chan)] (.readFile fs path "utf8" (fn [err data] ((go…
George
  • 6,927
  • 4
  • 34
  • 67
1
vote
2 answers

ClojureScript / OM: update a component's state from another component - or: working with global state

I'm getting started with om and ClojureScript with a very simple application. My global app-state looks like this: (def app-state (atom {:animals [ {:name "dog" :img "pic01.jpg"} {:name "cat" :img "pic02.jpg"} …
Anton Harald
  • 5,772
  • 4
  • 27
  • 61
1
vote
1 answer

Macros and defprotocol with Clojurescript

I'm using petrol for a clojurescript application, and I've found a lot of boilerplate is necessary when extending protocols with messages. So I decided to write a macro! Now, if only it worked :/ (ns my.macros) (defmacro state-message [msg-type…
munk
  • 12,340
  • 8
  • 51
  • 71
1
vote
4 answers

clojure: initialize 2d vector

in clojure I'm using the following function to initialize a 2d vector: (defn vec2d [x y init] (vec (map #(vec (map init (range x))) (range y)))) usage: (def grid (vec2d 40 30 (fn [] "x"))) Since I'm new to the language, I ask myself if…
Anton Harald
  • 5,772
  • 4
  • 27
  • 61
1
vote
2 answers

Clojurescript/Reagent Unit testing component - simulate onChange

For a component where I have a textbox, I need to be able to change the text in it from the test: (defn choose-city-component [] (let [inner-state (r/atom {:text ""})] (fn [] [:div [:input#txt_city { :type "text" …
Dan Bunea
  • 187
  • 1
  • 2
  • 10
1
vote
1 answer

reagent render multiple components

I've got two reagent components that will display on different pages of my web application. Tested individually, they both work exactly as they ought. When I try to render both of them, only one is displayed. Here is the clojurescript: (defn…
detran
  • 373
  • 2
  • 12
1
vote
1 answer

Clojurescript/Reagent handling errors

We are starting to use Clojuescript/Reagent for our next development phase of our product. Basically we need a way, to do a single operation on the atom and we came up with a method like: (def app-state (r/atom {})) (defn select [index] …
Dan Bunea
  • 187
  • 1
  • 2
  • 10
1
vote
1 answer

Clojurescript/reagent without automatic rendering

We wrote code with FB React before, using a single immutable app-state. However, we did the rendering like: model = immutable({name:"X"}); function change_name(name){ swap(render(change("name", name, model)))) } where render: function…
Dan Bunea
  • 187
  • 1
  • 2
  • 10
1
vote
1 answer

Clojurescript/Reagent Unit testing component output and behaviour

We used react for about one year now, with immutable data, very impressive. We now want to move to Clojurescript/Reagent, but we need a very good way to test our code. For components this is what we did: Test the output of the component, depending…
Dan Bunea
  • 187
  • 1
  • 2
  • 10
1
vote
1 answer

Putting data in a table in Clojurescript reagent

I'm building a ClojureScript app and I'm having trouble with using reagent to fill a table with data. The two issues I'm having are TONS of warnings of the form Every element in a seq should have a unique :key And also, as soon as I call the…
Christopher Shroba
  • 7,006
  • 8
  • 40
  • 68
1
vote
0 answers

image url to data URI in javascript

I request an image like this one: http://img0.ndsstatic.com/wallpapers/da9d3d05e8583820ef7337c3dd49c21c_large.jpeg and would like to convert the response to proper data URI I've tried to concat those: "data:" + respone.headers.content-type +…
szymanowski
  • 1,359
  • 1
  • 14
  • 25
1
vote
1 answer

Clojure prismatic/schema defrecord no enum runtime validation?

When using prismatic/schema, validation of enum on defrecord doesn't work, as shown here: (s/defrecord Action [type :- (s/enum :a :b)]) #'user/strict-map->Action user> (Action. "3") ; this should fail #user.Action{:type "3"} user>…
Nick
  • 167
  • 3
  • 9
1 2 3
99
100