clojurescript

Unable to display two components in OM

折月煮酒 提交于 2019-12-07 09:34:19
问题 I am attempting to learn Om, and have come across something I don't understand. I would expect this code (defn search-page-view [app owner] (reify om/IRender (render [_] (dom/div #js {:id "search-block"} "Test") (dom/div #js {:id "results-block"} "Test2")))) (om/root search-page-view app-state {:target (. js/document (getElementById "app"))}) to result in this html: <div id="app> <div id="search-block"> Test </div> <div id="results-block"> Test2 </div> </div> However, it does not! The first

A case-insensitive filter in Clojure / ClojureScript

為{幸葍}努か 提交于 2019-12-07 09:26:37
问题 I have this function : (defn list-data [alist filter-text] (filter (fn [x] (if (nil? filter-text) true (> (.indexOf x filter-text) -1))) alist)) (list-data ["Lion" "Zebra" "Buffalo" "Antelope"] "a") ;=> ("Zebra" "Buffalo") Is there a more idiomatic way of writing this function and respect the fact that I don't want a case-sensitive filter, meaning I would like that (list-data ["Lion" "Zebra" "Buffalo" "Antelope"] "a") returns the following: ;=> ("Zebra" "Buffalo" "Antelope") Thanks! (This

ClojureScript and closure: how to protect attributes from being renamed by closure

ぃ、小莉子 提交于 2019-12-07 08:46:11
问题 I am trying to to some HTML5 canvas drawing and I ran across a problem with the advanced compilation mode. I would like to exemplify this with the mozDash property of Mozilla browsers (although this question is quite generic on the attribute optimization feature) https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D#Gecko-specific_attributes The javascript canvas.mozDash = ... code can be expressed as [1] (set! (.-mozDash canvas) ...) or [2] (aset canvas "mozDash" ...) in

lein figwheel vs lein cljsbuild auto

安稳与你 提交于 2019-12-07 05:42:36
问题 What is the difference between lein figwheel and lein cljsbuild auto because I believe that they are both used to compile clojurescript. Also is there any benefit to using one over the other? 回答1: Fighweel They are both lein plugins but Figwheel not only compiles cljs into javascript but it also features hot loading which allows interactive programming, actually Figwheel uses cljsbuild for compiling cljs. You can create a figwheel app using: lein new figwheel app If you run: lein figwheel

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

让人想犯罪 __ 提交于 2019-12-07 01:24:55
问题 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. 回答1: ClojureScript provides good interoperability with JavaScript and the browser. You can call JavaScript globals and functions directly to query and manipulate DOM like so: (-> js/document (.getElementById "app") (.-innerHTML)) ; returns contents of element with id 'app' (-> js/document (.getElementById

How can I get the Clojurescript namespace I am in from within a clojurescript program?

别来无恙 提交于 2019-12-07 00:53:56
问题 How can I get the Clojurescript namespace I am in from within a clojurescript program? I want to do this do provide certain debug information (it only needs to work in dev mode) 回答1: Namespaces are not first class in ClojureScript as they are in Clojure. There's absolutely no way to get the namespace at runtime. It is possible to get this information at macroexpansion time if you're not afraid of accessing some the ClojureScript compiler internals. There should probably be an API for this -

Drag and drop events in embedded SVG?

这一生的挚爱 提交于 2019-12-06 20:37:07
问题 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 <ul id = "list"> <li class="item" id="item1">foo</li> <li class="item">bar</li> <li class="item">baz</li> </ul> And my script contains (Clojurescript/C2) (let [items (select-all ".item") lst (select "#list") target (fx/DragDrop. lst nil)] (dorun (map (fn [item] (let [source (fx/DragDrop. item nil)] (. source

Clojurescript Array-Map order

烈酒焚心 提交于 2019-12-06 09:21:51
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 true :c true :d false :b true :z false :h false :o true :p true :w false :r true :t false :g false}

Instantiate namespaced javascript class

早过忘川 提交于 2019-12-06 08:37:06
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. Using js/a.b.c.d is a bad practice and is likely to break in future versions of the compiler (because it is not a clojure compatible version of interop from what I

ArangoDB Foxx and Clojure script

拜拜、爱过 提交于 2019-12-06 06:47:18
问题 I'd like to implement a Foxx service using ClojureScript. I've read that one can use Typescript and Coffeescript by running the transpiler during each development step; Can I do similar for ClojureScript? 回答1: As far as we know, it is not possible to write ClojureScript applications in such a way that they could run in ArangoDB/Foxx. Unlike TypeScript and CoffeeScript, ClojureScript is not just a language but an application runtime. It's better to think of it not as an alternative syntax for