This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-01
Channels
- # adventofcode (1)
- # bangalore-clj (1)
- # beginners (8)
- # boot (47)
- # cider (6)
- # cljsrn (3)
- # clojure (155)
- # clojure-brasil (2)
- # clojure-china (3)
- # clojure-conj (1)
- # clojure-hk (4)
- # clojure-korea (36)
- # clojure-russia (38)
- # clojure-spec (53)
- # clojure-taiwan (1)
- # clojure-uk (14)
- # clojurescript (70)
- # clojurex (9)
- # component (2)
- # cursive (20)
- # datascript (19)
- # datomic (39)
- # defnpodcast (1)
- # events (5)
- # figwheel (2)
- # hoplon (81)
- # incanter (2)
- # jobs (7)
- # juxt (3)
- # klipse (1)
- # leiningen (1)
- # luminus (15)
- # mount (1)
- # off-topic (21)
- # om (5)
- # om-next (2)
- # onyx (19)
- # pedestal (2)
- # proto-repl (1)
- # proton (5)
- # re-frame (19)
- # reagent (4)
- # rethinkdb (2)
- # ring-swagger (6)
- # rum (13)
- # specter (6)
- # untangled (4)
- # yada (1)
I use reagent + re-frame + highcharts, when i run lein cljsbuild once min
, the code will erro like this image show.
@stevechan have you checked http://www.highcharts.com/errors/16 ? 🙂
@stevechan and how are you using Highcharts? It's easiest to use it via http://cljsjs.github.io/ — [cljsjs/highcharts "5.0.4-0"]
. In this case you also don't need any additional script tags.
That's good. Do you have the (:require [cljsjs.highcharts])
bit?
My guess would be that you also have a script tag loading highcharts, is that possible @stevechan ?
a <script>
tag in your HTML file
For some reason you are loading highcharts twice which is what the error is describing. Do you have an index.html
that you open in your browser?
yeah so basically delete the <script>
tags that load highcharts (first two lines in your screenshot)
Good luck 🙂
Heh, thanks! 🙂 Did it work?
Great, much success then 🙂
Anyone have any pointers on how to best pass environment variables to cljs at compile time? Currently, I’m using https://github.com/levand/immuconf
core.cljs render is : (r/render-component [my-highcharts-page] (. js/document (getElementById “app”)))
@chooie you can use a macro to reach into the env at compile time
@stevechan try with a very simple component like just (defn test-component [] [:h1 "Does this work?"])
@stevechan in this case it might help pasting your my-highchards-page
component
@martinklepsch Thanks!
(defn sampleHighchart-did-update [this]
(let [[_ tableconfig] (r/argv this)
my-chart-config (gen-chart-config-handson tableconfig)]
(do
(js/Highcharts.Chart. (r/dom-node this) (clj->js @my-chart-config)))))
(defn sampleHighchart [tableconfig]
(r/create-class {:reagent-render graph-view
:component-did-mount sampleHighchart-did-mount
:component-did-update sampleHighchart-did-update}))
(defn my-highchards-page [] [sampleHighchart @myconfig] )
(r/render-component [my-highcharts-page] (. js/document (getElementById “app”)))
@martinklepsch It seems that there is an issue with reader functions at compile time:
clojure.lang.ExceptionInfo: Error loading config file: resources/config.edn
data: {:file "wordroot_tasks/dev.clj", :line 13}
clojure.lang.ExceptionInfo: Error loading config file: resources/config.edn
data: {:file "resources/config.edn"}
java.lang.RuntimeException: No reader function for tag immuconf/override
Any ideas?render is here: (r/render-component [my-highcharts-page] (. js/document (getElementById “app”)))
@stevechan please use code formatting using triple backticks or slack's built in snippet feature (you can edit your previous message)
@chooie are you using boot or leiningen?
@chooie ok so the issue in this case is that the clojurescript compiler is ran in a pod and a previous call do load-data-readers!
is not affecting the state of data readers in this pod. You could try adding this (#'clojure.core/load-data-readers)
to your macro.
@martinklepsch Appreciate your time in doing that! I’m still getting the same exception. To give you an idea of what I’m doing: - build.boot is requiring a ‘dev’ namespace:
(require
...
'[wordroot-tasks.dev :as wordroot-dev])
...
- This is where I’m using the macro (in the wordroot-tasks.dev
ns):
(defn- init
[]
(let [config (config/get-dev-config)]
(reset! system (wr/wordroot-system config))))
- The maco definition:
(defmacro get-dev-config
[]
(#'clojure.core/load-data-readers)
(immuconf/load
"resources/config.edn"
"dev_config.edn"))
@martinklepsch , I have formated it . thanks 🙂
@chooie ok I think my macro suggestion probably wasn't very clear... What you need to do: 1. define a macro in a .clj file that reads your immuconf 2. require that macro in a .cljs file 3. use the macro in the cljs namespace to extract values from immuconf at compile time
@stevechan try wrapping graph-view
like this [:div graph-view]
@martinklepsch It didn't work
@stevechan did the div itself get rendered? (maybe try putting something else in there like [:h1 "test"]
)
@martinklepsch Thanks again! The macro is working perfectly when I use it in cljs. However, I’m getting that same error No reader function
that I had before on the clj side. I will keep digging into this and, in the meantime, follow the issue you made. Cheers!
@chooie yeah, that issue is unfortunately still relevant
You could try this in the macro as well:
(#'clojure.core/load-data-readers)
(set! *data-readers* (.getRawRoot #'*data-readers*)))
This is how boot.core/load-data-readers!
is defined, which you're probably using already@martinklepsch Just tried it and it introduces a problem in cljs:
adzerk.boot_cljs.util.proxy$clojure.lang.ExceptionInfo$ff19274a: ERROR: Can't change/establish root binding of: *data-readers* with set at file src/frontend/wordroot/routing.cljs, line 14, column 3
@martinklepsch , Thanks , It’s work ok now. 😄
Has anyone used js/FileReader
with re-frame? I'm trying to find a solution that would be more idiomatic than calling dispatch
from an event handler.
@p-himik why is dispatching from an event handler not idiomatic? Maybe share your code and ask for suggestions to improve it. 🙂
@martinklepsch there's hardly any code to share - just a single dispatch
inside a js/FileReader
's onload
. It's not idiomatic because re-frame's event handlers are supposed to be without side effects.
The only solution I can think of at this point (the point where ClojureScript doesn't have promise
and <!!
for some reason), is use js/FileReader
prior to any event handler - inside <input type="file">
's onchange
.
are there clear expectations for the :file
key in an analysis cache def, and how this should relate to :var-special output? I’m seeing variations of absolute vs. relative paths and extension vs. no extension for different kinds of names in caches: https://gist.github.com/mhuebert/4e826ab01e6684ef1413b15ef9edc547
I’d like to dedupe to reduce cache size, but not sure what is necessary & canonical vs. what can be derived, & unsure of implications of eliminating some of this (eg. absolute file paths are not desired at all for analysis caches that are to be shared/distributed.)