Fork me on GitHub
#clojurescript
<
2018-11-02
>
richiardiandrea04:11:49

Quick survey 😺 How long does builds take for you folks in average? I am being told node builds take 5-10 minutes and I want to make sure I am not doing anything wrong before answering. At the moment a monorepo build takes 22 minutes and it downloads ~50 deps. I am using shadow-cljs and no m2 caching between builds at the moment.

valtteri08:11:13

My whole stack (clj backend, cljs frontend with webpack double-bundle, tests) takes 7-8 minutes on Travis. This includes downloading deps and several Docker images. Monorepo. No caching.

richiardiandrea15:11:54

Thank you very much, it seems like I just have many deps to download. It might be shadow. I will investigate.

valtteri17:11:07

How long does it take if you run the same thing on your machine? 22 minutes sounds like eternity

richiardiandrea17:11:04

it is not a good comparison because I have .m2 always available, but it takes less 😄

valtteri17:11:57

I have setup where all CI-stuff runs in Docker and I have .m2 as shared volume. It’s easy to test it locally and nuke .m2 if necessary. 🙂

richiardiandrea20:11:39

thank you this looks very nice!

richiardiandrea20:11:31

checking now, I think I owe you a couple of 🍻

richiardiandrea20:11:45

the only thing I need to figure out now is how to share volumes on Azure but that looks fantastic

lilactown04:11:55

currently my builds take ~10 mins in CI

lilactown04:11:20

we cache the .shadow-cljs dir, node_modules and maybe m2?

richiardiandrea04:11:03

I have around ~ 10 repos and on Azure CI which makes it very tough to cache...I mean ...a docker image away I know but still,some work.

lilactown04:11:48

we have a monorepo but build the packages in parallel. currently only 1 CLJS package, with 3 builds that have to run within that package

lilactown04:11:42

installing deps, executing the builds, and building the docker container takes about 10 mins

richiardiandrea04:11:52

Yeah I do 4 parallel processes - four jvms as well. It seems most of the time is spent downloading the dependencies

richiardiandrea04:11:10

Good to know thank you very much it is helpful

lilactown04:11:41

sure thing 🙂

richiardiandrea04:11:14

I wish I were on CircleCi

sjol04:11:28

is there anyone working on an iOS clojurescript interpreter for iOS like pyhtonista? I saw that Apple's Siri shortcuts allow some amount of coding (https://www.reddit.com/r/shortcuts/comments/9hgblf/pythonista_and_shortcuts/)

Oliver George04:11:10

Is there such a thing as doing an optimised build without name mangling? I'm after the dead code elimination but would prefer not to pay the price of dealing with externs.

richiardiandrea04:11:40

Not sure about vanilla but you can with shadow-cljs, see the tests here: https://github.com/elasticpath/terraform-env-vars/blob/master/shadow-cljs.edn

Oliver George05:11:10

Thanks, I'll check it out.

thheller07:11:43

I'd suggest not setting :property-renaming and :variable-renaming at all and using the defaults instead

thheller07:11:53

:simple defaults to not renaming properties and only renaming local variables

Wagk09:11:47

Is it idiomatic in re-frame to directly query the db for something?

Wagk09:11:20

or must you dispatch an event?

kenran_09:11:00

I'm currently reading certain js properties this way: (let [index (when (pos? (alength elements)) (.-_index (aget elements 0)))]. Now I repeat this for some different properties. How can I pass the .-_index part as a function, so I can do (prop-fn (aget elements 0)?

kenran_10:11:12

Ah nvm, I can do (aget foo "_index") and pass the string.

kenran_10:11:38

I don't know whether there is a more idiomatic way of doing so though.

dominicm10:11:34

@johb.maier the a in aget stands for "array", you can't do this on maps, although it happens to work. It will break in the future.

dominicm11:11:28

I would be pro for a bot which links that article any time aget is mentioned.

4
kenran_11:11:40

Okay so I won't do that then. But is there a way to abstract over the property name? I don't mind using strings, but how can the -_index part in (-_index obj) be passed as argument?

mfikes12:11:37

@johb.maier Instead of (aget foo "_index") do (goog.object/get foo "_index")

mfikes12:11:31

If using :advanced and the property name can be renamed, goog.reflect/objectProperty looks promising. (Never used it myself.)

mfikes12:11:38

TBH, a challenge with that API is that the property name strings seem to need to be compile-time constants.

kenran_12:11:52

I'm not proficient with this (as can be guessed), but I don't think optimization is a problem in my case as they are fixed properties in chartjs.

kenran_12:11:00

Thanks, I will use goog.

mfikes12:11:27

Yeah, especially if it a foreign lib not being passed through Closure Compiler, :advanced is Ok if you use goog.object/get

dnolen13:11:56

@olivergeorge stepping back a bit - there's no need to be concerned about externs

dnolen13:11:02

inference works - so I think you're starting with a now old assumption

dnolen13:11:14

I haven't written a extern in the past 3 months

Oliver George13:11:44

Thanks David. That sounds perfect.

Wilson Velez13:11:40

@polkafreaku Have you seen the re-view/re-frame-simple project?

Wilson Velez13:11:30

you can do things like

db/get-in [:x :y :z]

Wilson Velez13:11:52

without the suscription

richiardiandrea16:11:17

How do folks package ClojureScript libraries with clj?

dnolen16:11:55

what do you mean?

martinklepsch16:11:16

@richiardiandrea Same as clojure? Pack, Sean's depstar etc. ?

richiardiandrea16:11:42

Uhm right haven't tried that yet. Thank you!

Wagk17:11:08

*wrt to reframe, I can't seem to find what's the second argument passed into reg-sub's computation function

Wagk17:11:28

all of the examples I've dug seems to ignore it

Wagk17:11:35

what is it?

Wagk17:11:24

@wvelezva no I haven't. I'll take a look

manutter5117:11:34

@polkafreaku The second argument to the reg-sub computation function is the argument that was passed to rf/subscribe. It's commonly ignored because often the only thing in it is the name of the subscription. If you want to pass more information to your subscription, though, you can do this:

(rf/reg-sub
  :demo/special
  (fn [db [_ extra-stuff]]
    (let [stuff (get-in db [:demo :special])]
      (str stuff extra-stuff))))

(subscribe [:demo/special "Hi, mom"])

Wagk18:11:01

Is there currently a way to target certain components during dispatch?

Wagk18:11:56

for example if I have two identical components, each displaying something (like a name maybe), and I want to update just one of the components

lilactown18:11:20

sounds like you have two different pieces of state

Wagk18:11:55

looks like it, yeah

Wagk18:11:52

would you recommend using reframe for a html game then?

Wagk18:11:29

I'd like to explore html/css using cljs, but games are notoriously stateful things.

lilactown18:11:48

depends on the game, IMO 🙂

lilactown18:11:27

I built a simple minesweeper game using just React and a reagent-ish framework I wrote

lilactown18:11:11

something that requires a lot of complex graphics & animations you might want to look at using canvas instead of HTML/CSS

lilactown18:11:37

with respect to that, I’m not sure how reagent does with canvas today

justinlee18:11:17

same as react: you can wrap the canvas in a component but then you are on your own

lilactown18:11:22

speaking of which… I’ve been working on a library as a thinner wrapper around React. I just whipped up a quick demo using the material-ui framework and I’m very impressed with how well it works! 😄 https://github.com/Lokeh/hx/blob/master/examples/workshop/material.cljs

👍 8
thheller21:11:41

if you want to get rid of this annoying [hx.react :as hx :include-macros true] :include-macros you can just add a #?(:cljs (:require-macros [hx.react])) in hx.react

thheller21:11:52

that'll make the macros available automatically

lilactown21:11:36

thanks! I have a plan to just separate the CLJ and CLJS into separate files in a bit, but that will make things easier to use for now

lilactown21:11:55

stretch goal is to support CLJ context and rendering to string as well, but not high on my list

lilactown21:11:13

obviously react hooks will make this better w.r.t. not requiring a class component to manage state, but I hope it will also remove the need for these gross HOC chains that so many React libraries promote