Fork me on GitHub
#clojurescript
<
2017-08-23
>
axl31600:08:43

Thanks! This is super helpful

axl31600:08:30

I'm pleasantly surprised at how awesome the reframe readme is!

thedavidmeister04:08:52

why can't protocols have a variadic signature?

thedavidmeister04:08:07

if i understand the changes in cljs 1.9.660 it appears that tests were added to ensure that the functionality works but also that warnings are thrown when it is used

thedavidmeister04:08:21

what's the rationale behind that?

thedavidmeister04:08:25

@dnolen i think this is something that you worked on?

anmonteiro04:08:53

@thedavidmeister the rationale is that it was never supported because it doesn’t work in Clojure either

anmonteiro04:08:08

the fact that it worked is an implementation detail

anmonteiro04:08:26

the tests were added to make sure the warning is produced

thedavidmeister04:08:18

hmmm, so how do we migrate something like hoplon to the newer version?

thedavidmeister04:08:39

if i have (div (div) (div) ...)

thedavidmeister04:08:49

there can be a lot of divs in there

thedavidmeister04:08:03

actually i have a real world example with arity 97 and it will likely continue to grow

anmonteiro04:08:28

I don’t know anything about Hoplon

thedavidmeister04:08:52

how much do you need to know?

thedavidmeister04:08:19

(div (div) (div)) = <div><div></div><div></div></div>

anmonteiro04:08:33

I don’t need to know anything at all

anmonteiro04:08:57

I’m merely stating that I don’t understand what you mean because I don’t know anything about Hoplon

thedavidmeister04:08:08

it's just an example use case

anmonteiro04:08:20

so that looks like a function call, you can use variadic functions

thedavidmeister04:08:24

i'm not saying "migrate hoplon" i'm saying, how do we migrate code like hoplon

thedavidmeister04:08:27

ah ok, so the extra info is that it's implementing IFn for js/Element

anmonteiro04:08:55

so div is somehow a macro that translates to a HTMLElement or however it’s called?

thedavidmeister04:08:23

(extend-type js/Element
 IFn
  (-invoke
   ([this & args] ...

thedavidmeister04:08:37

looks something like this pre 1.9.660

anmonteiro04:08:29

is that library code or user code?

anmonteiro04:08:46

not that it matters, I’m just curious

thedavidmeister04:08:46

that's in hoplon

anmonteiro04:08:40

so I suggest making that a single arg that takes a collection

thedavidmeister04:08:42

i don't think div is a macro, just a function

anmonteiro04:08:00

and div can take varargs and pass it as a collection

anmonteiro04:08:13

is that feasible?

anmonteiro04:08:36

might be better for perf too

thedavidmeister04:08:43

so you'd have to change (div (div) (div)) to (div [(div) (div)])?

thedavidmeister04:08:16

and actually it supports attributes too

thedavidmeister04:08:31

(div :class "foo" (div)) is currently allowed

anmonteiro04:08:54

if I understand correctly how it’s implemented in Hoplon, that’s not what I’m suggesting

thedavidmeister04:08:35

oh ok, can you give me an example?

thedavidmeister04:08:39

i think i'm missing something >.<

anmonteiro04:08:05

this is what I’m suggesting:

(extend-type js/Element
  IFn
  (-invoke [this args]
    ...))

(defn div [& args]
  ;; call the above with args
  )

thedavidmeister04:08:35

i'm not 100% sure that works out to equivalent functionality

thedavidmeister04:08:59

let me think about it

thedavidmeister05:08:15

currently i can do this

thedavidmeister05:08:19

(let [el (h/div)
       p (h/p)]
  (el :class "foo" p)

thedavidmeister05:08:31

and get <div class="foo"><p></p></div>

thedavidmeister05:08:23

as i understand hoplon div fn is just a convenience wrapper to create an element that is a div

thedavidmeister05:08:48

and then all DOM elements, whether created by hoplon or not, work in "the hoplon way"

anmonteiro05:08:33

I’m happy to look at a concrete minimal example that represents your problem

anmonteiro05:08:51

I shouldn’t be required to learn Hoplon to understand what you’re trying to solve, sorry

thedavidmeister05:08:23

well, if i do what you're suggesting

thedavidmeister05:08:27

doesn't ^^ break?

anmonteiro05:08:48

I don’t know

thedavidmeister05:08:49

i'd have to replace (el :class "foo" p) with (el {:class "foo"} [p]) right?

anmonteiro05:08:15

if h/div returns a function, just make that function varargs too?

thedavidmeister05:08:30

no, h/div returns a DOM element

thedavidmeister05:08:06

and dom elements are being extended to implement the IFn protocol so they can be called like functions

thedavidmeister05:08:32

sorry, i'm not the original author of this, i'm just trying to help get a PR up to use the latest version of cljs

thedavidmeister05:08:46

so i'm poking around as i go as well

anmonteiro05:08:38

I don’t have a good answer for that case then

thedavidmeister05:08:06

i am trying to give you as much relevant concrete info as i can

anmonteiro05:08:14

we may have to wait for David’s input

thedavidmeister05:08:28

(goog.dom/isElement (h/div)) this is true

anmonteiro05:08:59

btw if you’re implementing a protocol I’m quite certain you should be implementing all its arities

thedavidmeister05:08:46

there is no limit to the number of divs you can put in another div though

thedavidmeister05:08:17

actually that looks a lot like the current proposal in hoplon to workaround this

thedavidmeister05:08:36

but in my own project i already have a div with 97 children in it

thedavidmeister05:08:52

actual: #object[Error Error: Invalid arity: 97] 😞

thedavidmeister05:08:48

why is it so important that protocols cannot have a variable arity while it's ok for regular functions?

thedavidmeister05:08:20

that's some theory that i'm definitely missing

anmonteiro05:08:02

I also don’t know the answer to that question

anmonteiro05:08:17

it might be because of compat with Clojure

thedavidmeister05:08:37

oh ok, so something that works in js but not java?

max-tweddell05:08:08

How do you guys compile your reagent/cljs apps

max-tweddell05:08:11

so they aren’t huge

vikeri08:08:44

A question about the npm-deps flag in the compiler options. Is there a way to preprocess libraries with babel?

max-tweddell09:08:01

but i’m still getting 500kb files

rauh09:08:23

500kb gzipped?

quangh11:08:44

I hit the wall with npm-deps and react component. Can someone show me how to create Hiccup from :refer [component] in reagent?

Roman Liutikov13:08:32

Is cljs.spec supposed to be 100% eliminated under advanced optimizations? I’m seeing 20KB footprint in the output

yuriy.yarosh13:08:23

> Is cljs.spec supposed to be 100% eliminated under advanced optimizations? Yup. I, personally, do like it that way.

thheller14:08:41

no spec is removed by :advanced

yuriy.yarosh14:08:50

@thheller I don’t really think that’s the case with the current ClosureCompiler, thus I’m not quite sure about it.

yuriy.yarosh14:08:32

Nah, I’m wrong about it, it’s not getting removed… 😞

Roman Liutikov14:08:14

I’m on cljs 1.9.521 btw

devth15:08:09

trying to debug an issue where dev-only cljc files (e.g. js/superadmin/out/om/next.cljc and /js/superadmin/out/cljs/core.cljs) are attempting to be downloaded at runtime (observable in chrome console) from my advanced-compiled code inside an uberjar. these 404 as expected, since i only include the single advanced compiled js bundle. seems like i have some dev artifact lurking around. any suggestions on what to look for?

devth16:08:10

i can see hardcoded paths in the compiled js like:

$cljs$core$cst$0kw$0test$$], [$cljs$core$cst$0sym$0om$0next$$, $cljs$core$cst$0sym$0defui$$, 
    "resources/public/js/superadmin/out/om/next.cljc", 16, new $cljs$core$PersistentArrayMap$$(null, 5, [$cljs$core$cst$0kw$0variadic$$, !0, $cljs$core$cst$0kw$0max_DASH_fixed_DASH_arity$$, 3, $cljs$core$cst$0kw$0method_DASH_params$$, new $cljs$core$PersistentVector$$(null, 1, 5, $cljs$core$PersistentVector$EMPTY_NODE$$, [$cljs$core$list$$($cljs$core$cst$0sym$0_AMPERSAND_form$$, $cljs$core$cst$0sym$0_AMPERSAND_env$$, $cljs$core$cst$0sym$0name$$, $cljs$core$cst$0sym$0forms$$)], null), $cljs$core$cst$0kw$0arglists$$, 

currentoor18:08:59

does anyone know where the clojurescript compiler implements js*? I don’t want to use it, just curious what it looks like

max-tweddell20:08:47

@rauh its about 150kb gzipped

kenny21:08:15

What HTTP libs are you guys using when targeting nodejs?