clojurescript

Read in file with client-side clojurescript/re-frame app

谁说胖子不能爱 提交于 2021-01-28 05:41:02
问题 I'm writing a client-side application which should read in a file, transform its content and then export the result. To do this, I decided on Re-Frame. Now, I'm just starting to wrap my head around Re-Frame and cloujurescipt itself and got the following thing to work: Somewhere in my view functions, I send this whenever a new file gets selected via a simple HTML input. [:input {:class "file-input" :type "file" :on-change #(re-frame/dispatch [::events/file-name-change (-> % .-target .-value)])

ClojureScript split one namespace into multiple files

坚强是说给别人听的谎言 提交于 2021-01-27 04:43:51
问题 I've read this thread, but it seems like there are no load and load-file in ClojureScript. Is it possible to separate a single namespace over multiple files? The reason I want to do that is because I'm using Om and I want to separate components into different files. I can do it using separate namespaces, but then I will have to write the same requires in the beginning of each file and also the only way to call those components in the main file is like that: (:require [some-project.sidebar :as

Why are multi-methods not working as functions for Reagent/Re-frame?

旧时模样 提交于 2021-01-20 23:41:08
问题 In a small app I'm building that uses Reagent and Re-frame I'm using multi-methods to dispatch which page should be shown based on a value in the app state: (defmulti pages :name) (defn main-panel [] (let [current-route (re-frame/subscribe [:current-route])] (fn [] ;... (pages @current-route)))) and then I have methods such as: (defmethod layout/pages :register [_] [register-page]) where the register-page function would generate the actual view: (defn register-page [] (let [registration-form

Including JS files compiled using Figwheel to Uberjar built

感情迁移 提交于 2020-05-17 05:53:06
问题 Here is Figwheel config, app.cljs.edn ^{:watch-dirs ["src/cljs" "src/cljc"]} {:modules {:aff {:entries #{asaas.aff.aff} :output-to "target/public/js/aff.js"} :loc {:entries #{asaas.aff.loc} :output-to "target/public/js/loc.js"} :user {:entries #{asaas.user.user} :output-to "target/public/js/user.js"} :auth {:entries #{asaas.auth.auth} :output-to "target/public/js/auth.js"}} :output-dir "target/public/js/app" :asset-path "/js/app", } The problem is, it just works in dev . How should I go about

How to find the path of keys to a value in a nested array map in Clojure?

左心房为你撑大大i 提交于 2020-05-15 05:00:05
问题 Supposing I had: (def a-map {:foo "bar" :biz {:baz "qux"}}) How would I find the path of keys to a given value "qux" such that (get-in a-map <the resulting path>) would return "qux"? In other words, a function that takes a-map and "qux" and returns [:biz :baz]. I would then be able to use the returned path like this: (get-in a-map [:biz :baz]) and get "qux". The paths I need are going to be far more nested than this simple example. I am wanting to find the path to a given value in html that

(set! (.-onload image) (fn [] )) not working

戏子无情 提交于 2020-03-25 18:47:07
问题 I have the following code which takes as input some images and then compresses them using the compress-omg function, which takes a data-url of each image inputted in sequence and stores the compressed blobs in a db vector :images (defn image-selector [] [:<> ;; appending image in this div [:div {:id "test-div"}] [:input {:type "file" :multiple true :id "input-image" :on-change (fn [e] (let [files (array-seq (.. e -target -files))] (doseq [file files] ;; must create a new file-reader in each

How to hide/show a table in ClojureScript

本小妞迷上赌 提交于 2020-03-23 14:14:02
问题 I would like to show/hide a table when a font-awesome chevron button is clicked. The following code comes from http://jsfiddle.net/z0y0hp8o/6/. I would like to do the same thing, but in clojurescript using java interop. (document).on('click', '.panel-heading span.clickable', function(e){ var $this = $(this); if(!$this.hasClass('panel-collapsed')) { $this.parents('.panel').find('.specialCollapse').slideUp(); $this.addClass('panel-collapsed'); $this.find('i').removeClass('glyphicon-chevron-up')

How to hide/show a table in ClojureScript

纵然是瞬间 提交于 2020-03-23 14:12:18
问题 I would like to show/hide a table when a font-awesome chevron button is clicked. The following code comes from http://jsfiddle.net/z0y0hp8o/6/. I would like to do the same thing, but in clojurescript using java interop. (document).on('click', '.panel-heading span.clickable', function(e){ var $this = $(this); if(!$this.hasClass('panel-collapsed')) { $this.parents('.panel').find('.specialCollapse').slideUp(); $this.addClass('panel-collapsed'); $this.find('i').removeClass('glyphicon-chevron-up')

Tracking mouse in clojurescript / reagent / reagi?

99封情书 提交于 2020-02-03 04:30:34
问题 I'm trying to get to grips with reagent in clojurescript with a simple drawing program. I'm looking for an example of how to access the mouse position in a principled "FRP" inspired style with Reagi. In various reagent examples I can see things that look like this : [:p [:onmousemove (fn (evt) ...)]] to attach a handler to an element of the DOM. And to make a Reagi "behaviour" I want to write something like this : (def mouse-positions (r/behavior ( ... ))) But how do I combine these two so

Clojurescript date timepicker with cljsjs/react-day-picker

送分小仙女□ 提交于 2020-01-25 07:05:30
问题 I am new to clojure and clojurescript . I just to know how I can implement this library in clojurescript . This is the link to the library: https://react-day-picker.js.org/examples/basic I have required the library in my name space like so : (ns woot (:require [cljsjs.react-day-picker])) But I do not know how to proceed from here And when I try (js/react-day-picker) I get this error #object[ReferenceError ReferenceError: react_day_picker is not defined] (<NO_SOURCE_FILE>) 回答1: CLJSJS works by