clojurescript

How to Debug ClojureScript

点点圈 提交于 2019-12-20 09:17:05
问题 I apologize for this seemingly stupid question, but I've been playing with ClojureScript on and off for a few weeks now, and I can't figure out this one simple question: How do I debug ClojureScript? So here is the problem: I write my *.cjs files I run cljsc/build ... I load up my webpage. Something bad happens. I open up the firefox console. I get a line in the generated js, which I find incomprehensible, and I have no idea which line of the original cljs file it came from. My question: What

ClojureScript and HTML entities

◇◆丶佛笑我妖孽 提交于 2019-12-18 19:45:08
问题 I'm having trouble getting a non-breaking space into HTML via ClojureScript. If I use " " the string is simply printed literally. I'm using the Crate library. 回答1: Google's closure library that clojurescript leverages includes string helpers that will allow you to expand HTML entities. (require '[goog.string :as gstring]) (gstring/unescapeEntities " ") 回答2: Got it after reading: https://github.com/ibdknox/crate/issues/12 Basically, the issue seems to be that Crate inserts directly into the

How to prevent node from running out of memory when bundling js for React Native

独自空忆成欢 提交于 2019-12-18 15:16:22
问题 When bundling js for React Native using ClojureScript I got the following error. It seems that node runs out of memory when bundling the javascript bundle. This is probably more likely to happen when using ClojureScript since the resulting js files are generally bigger than vanilla js. FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory <--- Last few GCs ---> 152689 ms: Mark-sweep 1369.3 (1434.8) -> 1362.8 (1434.8) MB, 2794.5 / 0 ms [allocation failure] [GC in

Can't seem to require >!! or <!! in Clojurescript?

时光毁灭记忆、已成空白 提交于 2019-12-17 18:37:41
问题 I must be missing something very obvious here but I'm trying to setup a very basic program to put an item onto a channel then block until I can take it off again. The entire program is below: (ns shopping-2.core (:require [cljs.core.async :as async :refer [>!! <!! put! chan <! close! <!!]])) (let [c (chan)] (>!! c "hello") (.write js/document (<!! c)) (close! c)) The JavaScript error I'm getting is: Uncaught TypeError: Cannot call method 'call' of undefined I had that error before when I

How can I get Clojure :pre & :post to report their failing value?

。_饼干妹妹 提交于 2019-12-17 15:47:27
问题 (defn string-to-string [s1] {:pre [(string? s1)] :post [(string? %)]} s1) I like :pre and :post conditions, they allow me to figure out when I have put "square pegs in round holes" more quickly. Perhaps it is wrong, but I like using them as a sort of poor mans type checker. This isn't philosophy though, this is a simple question. It seems in the above code that I should easily be able to determine that s1 is a function argument in the :pre condition. Similarily, % in the :post condition is

How to share code between separate clojurescripts in the same project

浪子不回头ぞ 提交于 2019-12-14 03:10:03
问题 I have a project that compiles 2 scripts used in 2 pages of the app: :cljsbuild {:builds [{:source-path "src-cljs/search", :compiler {:output-to "resources/public/cljs/search.js" }} {:source-path "src-cljs/view", :compiler { :output-to "resources/public/cljs/view.js"}} ] I have code common for both scripts. How to share this code? The only way I have found is through a separate Clojure project - I execute 'lein install' on it and it is available to my ClojuresScript code as any other third

Polymer get element by id from shadow root

巧了我就是萌 提交于 2019-12-13 19:36:30
问题 I am not able to get an element by id that is in the shadow root. It will return nil. Here is the code. It is written in clojurescript. (p/defpolymer :query-component {:imports ["components/polymer/polymer.html"] :style ".query-container {margin: 20px; display: inline-block;}" :template [[:div.query-container [:div [:h4 {:style "display: inline-block;"} "Current Query"] [:button {:style "float: right; margin-top: 10px;" :on-click "{{runQuery}}"} "Run Query"]] [:span "{{query.name}}"] [:div

Project organization and cljsbuild config to require namespace

二次信任 提交于 2019-12-13 06:06:30
问题 How do I organize my project structure and configure cljsbuild to require my own namespace? For example in my project/src-cljs folder I have: └── project ├── file1 │ └── file1.cljs ├── file2 │ └── file2.cljs └─── required └── required.cljs I'd like file1.cljs (namespaced as file1.file1 ) and file2.cljs (namespaced as file2.file2 ) to require required.cljs (namespaced as required.required ). My :cljsbuild looks like: :cljsbuild {:builds [{:source-paths ["src-cljs/project/file1"] :compiler {

Problems with Clojurescript quickstart — build fails

依然范特西╮ 提交于 2019-12-13 02:55:40
问题 I'm trying to follow the Clojurescript Quick-Start I have downloaded the Clojurescript jar as described in the Quick-Start guide. I have verified that it has the appropriate size (about 19M). I have created the files. But when I try to build using the command: java -cp cljs.jar:src clojure.main build.clj Java returns the following stacktrace: Exception in thread "main" java.io.FileNotFoundException: Could not locate cls/build/api__init.class or cls/build/api.clj on classpath., compiling:(

Find Path to the First Occurrence in a Nested Data Structure

久未见 提交于 2019-12-13 02:46:23
问题 Consider the following numbers nested by vectors in a tree-structure (def tree [7 9 [7 5 3 [4 6 9] 9 3] 1 [2 7 9 9]]) My goal is to find the path to the first even number that can be found by traversing the tree: In the upper example this would be 4, the path from the root to this node would be [2 3 0] (def result [2 3 0]) I got some difficulties writing a function tho archive this. However, the following function finds the first even number, not its path: (defn find-even [x] (if (vector? x)