Fork me on GitHub
#clojurescript
<
2018-08-15
>
pesterhazy05:08:39

@jarvinenemil IMO you’re almost always better served by using js/fetch directly, even in cljs. Wrappers cause nothing but trouble

pesterhazy05:08:13

re-frame-http-fx wraps cljs-ajax, which wraps XhrIo, which wraps XHR...

restenb07:08:57

what's the correct cljs interop for this?

restenb07:08:14

'var server = new Highcharts(3003);'

dominicm07:08:43

(let [server (new Highcharts 3003)])

restenb08:08:46

I just get "Highcharts is not a constructor"

restenb08:08:00

same with (Highcharts. 3003)

restenb08:08:04

which confuses me

thheller08:08:09

probably js/Highcharts if you have it imported globally

restenb08:08:18

its a node module

restenb08:08:33

´(def Highcharts (node/require "highcharts-server"))´

debamitro14:08:32

Is it possible to compile.cljs files as Clojure? I have written some ClojureScript code and my most important namespace has got nothing to do with JavaScript. I’d like to be able to use it as both Clojure and ClojureScript. I am using leiningen and cljsbuild - nothing else.

miikka14:08:04

Yes. You need to rename the cljs file from .cljs to .cljc. If the file contains some parts that should be different for Clojure and ClojureScript, you can use reader conditionals which are explained here: https://clojure.org/guides/reader_conditionals

miikka14:08:22

Oh, and you need make sure that the file is in a directory that can be seen both by the Clojure and ClojureScript side – maybe it already is. So you want to have the file in directory that is in Leiningen's and cljsbuild's :source-paths

dnolen14:08:13

@restenb that should work

polymeris16:08:25

A propos cljc, how do you test errors in a portable way? I tried:

(def assertion-error
  #?(:clj  java.lang.AssertionError
     :cljs js/Error))
;...
(is (thrown-with-msg? assertion-error #"Assert failed: (map? x)" (sut)))
but clj doesn't like it: java.lang.IllegalArgumentException: Unable to resolve classname: assertion-error

polymeris17:08:34

(that regex is wrong, too)

miikka17:08:34

I think you need to inline assertion-error. thrown-with-msg? is part of clojure.test macro magic and using variables in there is not going to work. 😐

polymeris18:08:10

Hmm, makes sense. Maybe the best way is to create an is-thrown-with-msg? macro that ouputs that whole (is ...) line

kennytilton17:08:10

I am making pseudo-announcements here just to pre-flight the doc on my new CLJS Web framework. The Real Deal will come after some reference doc to go with the intro scenery chewing. This should be the last in the chewing trilogy. https://github.com/kennytilton/mxtodomvc/blob/master/documentation/InDepth.md It is a fun reminder of how much of the UI code Mr. Hickey dreads can be automated. As always, feedback welcome.

👍 8
bhauman20:08:44

For figwheel.main:

bhauman20:08:16

I know some folks have this set up and its really working well for them. This will make it much easier.

idiomancy21:08:15

does garden just totally lack the @supports query?

idiomancy21:08:22

man bummer. yeah there's no feature queries.. @noprompt any plans or thoughts or workarounds?

noprompt21:08:10

@idiomancy mmm. there’s no direct support for it but i think you could add it pretty easily.

idiomancy21:08:49

I see, just wouldn't be hierarchical like the at-media rule fn

noprompt21:08:18

i forget the semantics of @supports but i think at some point i was messing with that.

idiomancy21:08:07

could I just add a defmethod to extend the compiler and a new CSSRule...hmmm

noprompt21:08:21

something like that.

noprompt21:08:38

i’ve been working on a top secret project for a little while now and haven’t given garden attention in a bit.

noprompt21:08:56

the work i was doing on the 2.0.0 branch makes stuff like that really easy though.

idiomancy21:08:31

well, you've earned your secret project time. this stuff is really handy and you're awesome 😄

idiomancy21:08:47

i'll keep an eye out for 2 and hack something in

noprompt21:08:54

thanks. i’m grateful to hear people still enjoy using it!

noprompt21:08:29

heh, if i get some front end opportunities, that’ll probably motivate me to hack on it some more.

noprompt21:08:37

been on the backend for a few years now. 😭

idiomancy21:08:46

lol, here's hoping

kenny23:08:05

I am running into a strange issue when enabling Spec instrumentation and haven't figured out how to reproduce it yet. Curious if anyone can shed some light on this issue. I have a function that takes arguments like this [x y z & more]. It has a fdef that looks like this:

(s/fdef reg-query-sub
        :args any?
        :ret fn?)
I am calling reg-query-sub like this: (reg-query-sub :a {} []). When instrumentation is enabled, I get this error thrown in the console:
Error: :a is not ISeqable
    at Object.cljs$core$seq [as seq] (core.cljs:1223)
    at Object.cljs$core$bounded_count [as bounded_count] (core.cljs:3725)
    at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (core.cljs:3888)
    at Function.G__40458__delegate [as cljs$core$IFn$_invoke$arity$variadic] (alpha.cljs:112)
    at compute$ui_frontend$re_frame$reg_query_sub (re_frame.cljs:217)
    at Object.cljs$core$apply_to [as apply_to] (core.cljs:3845)
    at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (core.cljs:3890)
    at Object.G__40458__delegate (alpha.cljs:112)
    at Object.G__40458 [as reg_query_sub] (alpha.cljs:107)
    at eval (subs.cljs:31)
Because that error seems to be incorrect, I enabled the debugger in Chrome and set it to pause on caught exceptions. Walking down the call stack, I inspect the values of the vars in scope. When I get to G__40458__delegate (the 4th item in the stack), I see the value for args is :a, which is incorrect thus the error. Continuing the walk down, I see G__40458__delegate again (8th item in the stack). This time its args are a vector of the items I passed it - [:a {} []]. Moving down the stack one more level I get to G__40458 which has several definitions of args. The first 3 are correct, but the last one is :a. I'm not really sure how to go about debugging this issue any further. Does anyone have any thoughts?

kenny23:08:07

Hmm, evaluating args in the console when on the 8th and 9th frame yields the expected value for args. Evaluating on the 4th frame returns just :a.

kenny23:08:38

FWIW, reg-query-sub calls another function that has instrumentation enabled.

kenny23:08:04

Changing my reg-query-sub to take args like this: [x y z more] fixes the issue. Pretty sure there is a bug here with varargs and instrumentation.