Fork me on GitHub
#clojurescript
<
2017-10-31
>
p-himik10:10:46

When using :process-shim, env.js is created but it's loaded way after most of other JS files which causes multiple process is not defined errors in my case. Is it something that's easy to fix?

mfikes11:10:41

@xiongtx It depends on which REPL you are in and how it handles printing. Lumo and Planck behave like your Clojure example.

xiongtx17:10:59

Hmm, I’m in the cider REPL. You’re saying is is a cider 🐛 then?

mfikes11:10:16

You can force the issue by using something like (with-out-str (doseq [x [1 2 3]] (cljs.pprint/cl-format true "~A" x)))

mfikes11:10:50

You can see it is just a REPL/extra-newline issue by looking at the behavior of pr with (do (pr 1) (pr 2) (pr 3))

p-himik11:10:32

So apparently the documentation at https://clojurescript.org/reference/compiler-options#preloads is a bit misleading in saying that :preloads work right after cljs.core is loaded. :preloads are included right after all dependencies have been loaded. And many libraries in NPM check process.env during loading. Hence, it's impossible to set process.env using only preloads in such a way so that no libraries break.

tatut16:10:09

I’ve used clojurescript for a long time, but I’m still not really comfortable with externs.

tatut16:10:59

how does one go about debugging externs problems? for example the leaflet map extern has addControl method, but in my project calls to it are still getting munged

spinningtopsofdoom16:10:48

Turning on pseudo-names for debugging the compiled code. Externs Inference (https://clojurescript.org/guides/externs) to try and debug things during compile time.

tatut16:10:22

:infer-externs true and a sprinkling of type hints seems to solve it in my case

maleghast17:10:15

Hello All - brand new CLJS n00b here… I am using reagent, and I can get some basics sorted, but I have two questions… 1. Can I make the target of an onclick be a CLJS function that will grab some data, hide a section and then initialize the same section with a new component? 2. Is there a good way to separate the functionality / logic from the components, or do I need to just accept that the logic and presentation are a bit colocated?

p-himik17:10:37

I'm trying to use https://github.com/souporserious/react-measure in my project. I specified the dependency using :npm-deps, and everything is fine up to the moment when I actually try to render the wrapped component:

Uncaught TypeError: _resizeObserverPolyfill2$$module$home$p_himik$dev$git$musicxmlcheck_test$node_modules$react_measure$lib$with_content_rect.default is not a constructor
The check of the objects quickly shows that it's being wrapped by _interopRequireDefault into {default: ...} two times:
_resizeObserverPolyfill2$$module$home$p_himik$dev$git$musicxmlcheck_test$node_modules$react_measure$lib$with_content_rect: Object
default:
  default: λ[callback]
Has anyone seen anything like it?

p-himik17:10:47

@maleghast Regarding your second question, you can check out re-frame library. For me it works great.

maleghast17:10:59

@p-himik Thanks for the tip, I may indeed look at re-frame, but right now, I need to get some stuff working…

Joe G18:10:14

does anyone know of a good sparkline library?

Joe G18:10:07

im having trouble finding one that is react-like

p-himik18:10:13

@jgreen I successfully used Highcharts: https://www.highcharts.com/demo/sparkline The library itself is not react-like, but it's easy to make it work in a component.

tatut18:10:20

http://recharts.org is also a nice charting lib for react

tatut18:10:45

but there seems to be at least a couple of react sparkline libs (by quick google search), don’t they work?

Joe G18:10:49

@tatut i guess i was looking for one with a cljsjs dependency

tatut18:10:10

recharts should work then

tatut18:10:38

if you just use a small linechart without a grid or axis, that should basically be the same as a sparkline

Joe G18:10:30

@tatut good idea. thanks 🙂

eggsyntax20:10:07

I am confused:

cljs.user> (pos? "3")
----  Compiler Warning on   <cljs form>   line:1  column:1  ----
cljs.user> (#(pos? %) "3")
true
cljs.user> (#(pos? %) "-3")
false
Can anyone help me understand what's going on there?

anmonteiro20:10:23

@eggsyntax pos? is both a function and a macro

anmonteiro20:10:44

in the first snippet you’re calling the macro, which can statically verify you’re not passing it a number

anmonteiro20:10:17

the other snippets are calling the function and the string gets implicitly casted to a number which is why it works

anmonteiro20:10:37

(casted by the underlying JS host, I should say)

eggsyntax20:10:12

Gotcha, thanks @anmonteiro. I was worried it was some sort of Halloween spookiness.

eggsyntax20:10:45

@anmonteiro can you tell me where to find info on that dual existence as function and macro? I assume it's not unique to pos?, and would like to understand it better.

eggsyntax20:10:12

I'm guessing that's

(core/defmacro ^::ana/numeric pos? [x]
  `(> ~x 0))
in cljs.core.cljc.

anmonteiro20:10:55

and the function is in cljs/core.cljs

mfikes21:10:26

@eggsyntax If you are interested in the subject of ClojureScript Vars that can be both macros and functions, here is a post on it: http://blog.fikesfarm.com/posts/2015-12-12-clojurescript-macro-functions.html

eggsyntax00:11:50

Terrific, thanks! I'll go read through it right now. I've gotten closer to understanding it just by digging through the code & reading the brief mentions on https://clojurescript.org/about/differences , but it's still pretty shaky...

fbielejec22:10:29

Hi, has anyone played with options for server-side rendering a reagent + re-frame app? Is https://prerender.cloud a good option?