clojurescript

How do I deploy a single-page app. written in ClojureScript / Figwheel to a static server?

拈花ヽ惹草 提交于 2019-12-23 07:38:34
问题 I'm playing with Figwheel and writing a simple single-page app that doesn't require any server-side intelligence. In principle, this app. could be placed on any static web-server. But how do I actually deploy it? It looks like the main.js which is in my Figwheel development environment is setting up the figwheel connection. What js and html files do I actually need to put on my static server? Has Figwheel created them, or do I need to create a new main.js and index.html? And where can I find

Generate javascript method call code with ClojureScript macro?

点点圈 提交于 2019-12-23 03:31:13
问题 I am using ClojureScript to detect which browser-specific version of 'requestAnimationFrame' method is defined. I use the following code: (defn animationFrameMethod [] (let [window (dom/getWindow) options (list #(.-requestAnimationFrame window) #(.-webkitRequestAnimationFrame window) #(.-mozRequestAnimationFrame window) #(.-oRequestAnimationFrame window) #(.-msRequestAnimationFrame window))] ((fn [[current & remaining]] (cond (nil? current) #((.-setTimeout window) % (/ 1000 30)) (fn? (current

Generate javascript method call code with ClojureScript macro?

冷暖自知 提交于 2019-12-23 03:31:04
问题 I am using ClojureScript to detect which browser-specific version of 'requestAnimationFrame' method is defined. I use the following code: (defn animationFrameMethod [] (let [window (dom/getWindow) options (list #(.-requestAnimationFrame window) #(.-webkitRequestAnimationFrame window) #(.-mozRequestAnimationFrame window) #(.-oRequestAnimationFrame window) #(.-msRequestAnimationFrame window))] ((fn [[current & remaining]] (cond (nil? current) #((.-setTimeout window) % (/ 1000 30)) (fn? (current

Clojurescript Array-Map order

末鹿安然 提交于 2019-12-22 14:52:54
问题 How can I keep order in array-map? Array-map with a length above 8 behaves completely different in Clojure and Clojurescript. Example: cljs (array-map :a true :c true :d false :b true :z false :h false :o true :p true :w false :r true :t false :g false) -> {:o true, :p true, :r true, :t false, :w false, :z false, :a true, :b true, :c true, :d false, :g false, :h false} clj (array-map :a true :c true :d false :b true :z false :h false :o true :p true :w false :r true :t false :g false) -> {:a

Clojurescript Array-Map order

99封情书 提交于 2019-12-22 14:52:19
问题 How can I keep order in array-map? Array-map with a length above 8 behaves completely different in Clojure and Clojurescript. Example: cljs (array-map :a true :c true :d false :b true :z false :h false :o true :p true :w false :r true :t false :g false) -> {:o true, :p true, :r true, :t false, :w false, :z false, :a true, :b true, :c true, :d false, :g false, :h false} clj (array-map :a true :c true :d false :b true :z false :h false :o true :p true :w false :r true :t false :g false) -> {:a

Instantiate namespaced javascript class

[亡魂溺海] 提交于 2019-12-22 14:02:03
问题 I want to use google maps api v3, and it needs me to instantiate google.maps.LatLng . Using clojurescript this is what I do: (ns foocljs.core) (LatLng. (.-maps js/google) 100 100) I got an error undefined is not a function , this is the culprit: new foocljs.core.LatLng(foocljs.core.google.maps, // ... another args I'm guessing this is because the compiler think that LatLng. is clojure namespaced class. How to deal with this? Thanks. 回答1: Using js/a.b.c.d is a bad practice and is likely to

re-frame: nvd3 graph doesn't respond to when its component's subscriptions are updated

▼魔方 西西 提交于 2019-12-22 11:28:08
问题 I'm using the re-frame cljs framework which uses reagent as its view library. I have an nvd3 graph component that I want to be updated when its subscriptions update. Unfortunately, the graph never updates itself after the initial call to :component-did-mount . :component-will-update is never called again after the intial render. I want the graph to update itself as the subscription notifies the components of the dat it's listening to being changed. Here's the graph-container component: (defn

How to memoize a function that uses core.async and non-blocking channel read?

百般思念 提交于 2019-12-22 08:57:36
问题 I'd like to use memoize for a function that uses core.async and <! e.g (defn foo [x] (go (<! (timeout 2000)) (* 2 x))) (In the real-life, it could be useful in order to cache the results of server calls) I was able to achieve that by writing a core.async version of memoize (almost the same code as memoize): (defn memoize-async [f] (let [mem (atom {})] (fn [& args] (go (if-let [e (find @mem args)] (val e) (let [ret (<! (apply f args))]; this line differs from memoize [ret (apply f args)] (swap

ClojureScript map lookup slow

无人久伴 提交于 2019-12-22 08:54:09
问题 I have a simple map: (def my-map {[1 2 3] 1 [1 2 4] 5 [3 4 2] 3 [4 5 3] 3 [5 2 5] 6 [9 2 1] 5 [8 3 1] 6}) that I use for performing lookups. This performs rather poorly, however: (time (doseq [x (range 500)] (my-map [1 2 8]))) "Elapsed time: 170 msecs" On the same machine, Clojure can do 500,000 in about 236 msecs, or about 700x faster. While it's not unexpected for Clojure to be faster than ClojureScript, I'm confused why ClojureScript would be so much slower. Any ideas about how I could

How can I deploy a Leiningen template to Clojars?

大兔子大兔子 提交于 2019-12-22 08:07:41
问题 I have created a Leiningen project on my local machine which I then turn into a template by doing: lein create-template webdb : Then I install the template: cd webdb lein install : which allows me to create projects based on the template locally: lein new webdb anewproject : Everything works fine up to here. However if I try to deploy the template to clojars using: cd webdb lein deploy clojars : then whenever I try to use the clojars profile to create a template I get an error: lein new org