Fork me on GitHub
#clojurescript
<
2016-12-01
>
hulunote02:12:01

I use reagent + re-frame + highcharts, when i run lein cljsbuild once min , the code will erro like this image show.

hulunote02:12:04

But run my code in lein figwheel is ok.

martinklepsch03:12:24

@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.

hulunote03:12:55

I no use :as or :refer to require it

martinklepsch03:12:30

That's good. Do you have the (:require [cljsjs.highcharts]) bit?

martinklepsch03:12:56

My guess would be that you also have a script tag loading highcharts, is that possible @stevechan ?

martinklepsch03:12:23

a <script> tag in your HTML file

martinklepsch03:12:20

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?

hulunote03:12:02

My html like this

martinklepsch03:12:54

yeah so basically delete the <script> tags that load highcharts (first two lines in your screenshot)

hulunote03:12:26

let me try 👍 ,thanks

martinklepsch03:12:32

Good luck 🙂

hulunote03:12:47

which id is your github?

hulunote03:12:43

very nice 👍

hulunote03:12:43

I following you 😜

martinklepsch03:12:26

Heh, thanks! 🙂 Did it work?

hulunote03:12:19

Yes, It’s work ok now . 😗

martinklepsch03:12:40

Great, much success then 🙂

chooie04:12:03

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

hulunote05:12:35

It’s not work

hulunote05:12:47

The console not show any error

hulunote05:12:57

The page can’t render

hulunote05:12:42

the index is :

hulunote05:12:08

core.cljs render is : (r/render-component [my-highcharts-page] (. js/document (getElementById “app”)))

martinklepsch05:12:02

@chooie you can use a macro to reach into the env at compile time

martinklepsch05:12:07

@stevechan try with a very simple component like just (defn test-component [] [:h1 "Does this work?"])

hulunote05:12:55

simple component can show

martinklepsch05:12:10

@stevechan in this case it might help pasting your my-highchards-page component

hulunote05:12:04

(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”)))

chooie05:12:08

@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?

hulunote05:12:23

Thanks 🙂

hulunote05:12:19

render is here: (r/render-component [my-highcharts-page] (. js/document (getElementById “app”)))

martinklepsch05:12:04

@stevechan please use code formatting using triple backticks or slack's built in snippet feature (you can edit your previous message)

martinklepsch05:12:16

@chooie are you using boot or leiningen?

martinklepsch06:12:54

@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.

chooie06:12:05

@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"))

hulunote06:12:13

@martinklepsch , I have formated it . thanks 🙂

martinklepsch06:12:57

@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

martinklepsch06:12:41

@stevechan try wrapping graph-view like this [:div graph-view]

martinklepsch06:12:27

@stevechan did the div itself get rendered? (maybe try putting something else in there like [:h1 "test"])

hulunote06:12:01

I don’t konw how to debugger it and what’s error happed.

chooie07:12:40

@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!

martinklepsch07:12:32

@chooie yeah, that issue is unfortunately still relevant

martinklepsch07:12:29

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

chooie07:12:01

@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

hulunote07:12:27

@martinklepsch , Thanks , It’s work ok now. 😄

p-himik12:12:59

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.

martinklepsch12:12:08

@p-himik why is dispatching from an event handler not idiomatic? Maybe share your code and ask for suggestions to improve it. 🙂

p-himik13:12:59

@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.

mhuebert15:12:34

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.)

thheller19:12:36

@mhuebert probably a topic better suited for #cljs-dev

dpsutton20:12:12

anyone use clojurescript with boot? Running into an issue with jacking into clojuresscript from CIDER with boot

dpsutton21:12:19

and really trying to find out how boot cljs users use CIDER

dpsutton21:12:29

is the standard making your own repl and running cider connect?

hiron22:12:00

cider-jack-in-clojurescript should work