Fork me on GitHub
#clojurescript
<
2017-07-12
>
tjscollins01:07:34

Does anyone have experience working with reagent and generating large tables? I'm having trouble with reagent just dying trying to render 1000+ rows which seems like it shouldn't happen. Sometimes it's even dying on just 100 rows, although not every time.

danielcompton01:07:06

You can use Chrome devtools to record a CPU profile to see where the time is being spent (sorting and preparing the list, or rendering to the DOM)

tjscollins01:07:29

@danielcompton Thanks. Had never used the profiler before. The problem turned out to be access-lint checking the DOM as it re-rendered. Disabling it fixed the problem. Something about the react re-renders the dom must not play nice with it.

madvas02:07:33

Guys, when interacting with REPL with clojurescript node.js, how can I prevent program from exiting on error?

vargaradu08:07:31

What techniques do you use for cache-busting your clojurescript web app? I’m particularly interested in how to invalidate the cache for app.js, but also html and css would be nice.

thheller17:07:47

so I rename app.js to app.<md5hash>.js and load that instead

shidima_12:07:34

Hmm, i'm getting an error i dont understand and googeling is not making it more clear: No protocol method ISwap.-swap! defined for type cljs.core/PersistentArrayMap It comes from this code:

(defn mark-as-done [todo-item]
  (if (= (:done todo-item) "active")
    (swap! (assoc todo-item :done "done") todo-item)
    (swap! (assoc todo-item :done "active") todo-item)))
a todo-item is {:id "1", :title "test", :done "active"}

shidima_12:07:13

I think i'm (again) implementing swap! wrong

moxaj12:07:41

@shidima_ not sure what you're trying to do there, swap! is for atoms

shidima_12:07:11

I have a r/atom with db results todos, i have an onclick handler that calls the mark-as-done to update the state of the one todo item

shidima_12:07:00

I think that what i'm doing wrong is that the singel todo item is not an atom

dnolen12:07:45

@wilkerlucio missed this yesterday you don’t need to bother with :advanced to get some big speed boosts - just use :static-fns true

wilkerlucio12:07:31

@dnolen thanks, I'll do that 🙂

dealy14:07:09

I've just packaged (w/Uberjar) and deployed my cljs app for the first time. When running the deployed app one of the 3rd pary JS libs isn't found, all the others seem to be fine. I've opened the packaged jar file and see the JS lib in the right place. Any suggestions on how to troubleshoot this?

dnolen14:07:40

@dealy deploying a cljs app generally means :advanced compilation, you won’t have separate files (unless using code splits)

dealy14:07:02

thanks for the tip, reading up on :advanced now

dnolen14:07:55

@dealy hrm if you haven’t tried this before then it may be bumpy for a little bit - it’s generally important to try :advanced early and often

dealy14:07:49

yea I see that in the docs I'm reading now, I was hoping to get this out today, bummer

dnolen14:07:53

@dealy a minor detail is that people often put the production JS on a CDN & enable gzipping

dnolen14:07:04

@dealy if you’re in a jam, then :simple works, though your clients will download a larger payload

dealy14:07:24

oh, well that will help, this is actually for internal use only

akiroz17:07:13

I'd love to know this too! Right now I'm manually incrementing a version on my script tag src's query string and disabling the browser's cache completely during development........ I wonder if there's some kinda tooling for generating the html file that requests my script using a unique id for each build....

rnagpal17:07:27

Any simple way or shortcut to run tests from intellij(Cursive plugin)

rgdelato17:07:57

@rnagpal maybe try asking in #cursive ?

yedi17:07:25

is it possible to subscribe to changes made to a re-frame app-db ratom?

rnagpal17:07:57

(defn play-game []
  (let [
        matrix-size (re-frame/subscribe [:matrix-size])
        matrix-cells (re-frame/subscribe [:matrix-cells])
        user-selection-matrix (re-frame/subscribe [:user-selection-matrix])
        ]
    (r/create-class
@yedi

benbot18:07:00

Is there a maintained fork of Domina? Or something like it

mobileink18:07:28

For anybody interested in helping out with JS interop docs: https://github.com/clojure/clojurescript-site/pull/95 . the original is the interop-ref branch at https://github.com/mobileink/clojurescript-site/tree/interop-ref . This is a very rough draft (and I’ve got more material to add), but at the least it functions as a list of stuff that needs to be covered. Not sure what the best way to pitch in is, I guess a note on this channel or you can DM me.

mobileink18:07:31

What’s the interop story for deftype? If I construct a value from a deftype, can I pass it to a fn in a Javascript library and expect hunkydoriness? More specifically, I’m looking at expressing ES6 classes (with extend) in cljs. I’ve found code on the web showing how to do this in earlier JS syntax, but it’s pretty hairy (to me). How close is deftype to supporting this sort of thing? Note that I’m willing to hack up a deftype variant if need be, I’ve done that sort of thing before. But I’m a little shaky on the JS side of things, not sure if it would make sense.

dnolen18:07:28

deftype is not about interop, never was

dnolen18:07:20

making definition of ES6 classes easier might happen - but I doubt it will have anything to do with deftype

dnolen18:07:47

but given the wide range of features required, probably won’t happen

dnolen18:07:17

ClojureScript can handle mixed codebases if you want to make a ES6 class just make a ES6 class

dnolen18:07:27

(in a JS file)

chrisbroome18:07:26

for what it's worth, ES6 classes are just syntactic sugar on top of the existing JS prototype model

chrisbroome18:07:19

I have almost no clojure background (just joined this slack yesterday), but I've done JS a long time, and I would say that unless you absolutely need to use the prototype (i.e. for extreme performance), just stick to factory functions that return objects

henrik18:07:57

Brilliant stuff @dnolen

henrik18:07:42

I particularly look forward to trying it out on Node in lieu of my current strategy (which is adding JS libraries manually, referring them globally, and then hating myself)

dnolen18:07:57

@henrik there’s fixes for that also forthcoming in the next release - there’ll be a separate post about that next week

dnolen18:07:25

theme of the next release is definitely “Grand Unification”

yedi18:07:40

@dnolen is that referring to making it easier to import JS libraries via a CLJS build process

roklenarcic18:07:56

hm how large is a minimal hello world om.next application after :advanced compilation supposed to be

roklenarcic18:07:23

I get 500kB app and the only thing I use is om.dom and compassus (and core om of couse)

anmonteiro18:07:55

@roklenarcic do you have (enable-console-print!) somewhere in your code?

anmonteiro18:07:07

that accounts for at least 90KB

roklenarcic18:07:46

Is there some way to make it dev only?

roklenarcic18:07:45

The options I use for min build are :static-fns true :closure-defines {goog.DEBUG false} :optimizations :advanced :pretty-print false

anmonteiro18:07:46

(when ^boolean goog/DEBUG
  (enable-console-print!))
and add {:closure-defines '{goog.DEBUG false}} to your compiler options

anmonteiro18:07:07

you may also want to throw :elide-asserts true in there

roklenarcic18:07:36

btw is typehinting needed a lot?

anmonteiro18:07:45

might not be needed in this case

anmonteiro18:07:54

you don’t need to think about type hinting no

anmonteiro18:07:05

and in ClojureScript the only thing that matters is boolean anyway

anmonteiro18:07:35

@roklenarcic you can use something like https://github.com/danvk/source-map-explorer to see what’s in your bundle

anmonteiro18:07:41

provided you generate source maps

anmonteiro18:07:53

though foreign libraries won’t show up in there

roklenarcic18:07:01

does {goog.DEBUG false} needs to be qoted?

anmonteiro18:07:06

and React+React-DOM accounts for like 130KB?

roklenarcic18:07:28

yeah I know, but I use very little of it

anmonteiro18:07:32

if you’re using Lein or something then things are implicitly quoted

anmonteiro18:07:02

> I use very little of it there’s no DCE on foreign libraries

anmonteiro18:07:20

they’re simply prepended to the generated bundle. So you’re getting it all

roklenarcic18:07:16

will look into it

roklenarcic18:07:33

after I added material-ui, my rather trivial app is at 1.1MB

roklenarcic18:07:41

this may be a dumb question: what's the benefit of babel?

sundarj18:07:57

depends what you use it for, it can be used to write es7 code that gets transpiled to es5, or it can just be used to turn jsx into js react understands

sundarj18:07:05

not sure if it's used in cljs anywhere

roklenarcic19:07:05

all this compiling and packaging work is rather confusing for a java/clojure developer TBH 😄

yedi19:07:59

i think its also confusing for JS developers

timgilbert19:07:45

Say all, with the latest cljs build, post clojure/spec -> clojure.spec.alpha split I'm requiring [clojure.spec.alpha :as s] in my source. Am I correct that I should now be looking for :clojure.spec.alpha/invalid as a result of (s/conform)on both JVM and JS platforms, rather than :cljs.spec/invalid on JS?

dnolen19:07:35

@timgilbert no in ClojureScript we’re just ns aliasing for you but the namespaces are not changed, nor values

dnolen19:07:49

:cljs.spec/invalid

timgilbert19:07:42

Ok, cool. Just curious, is that likely to get normalized once clojure.spec comes out of alpha? Not the biggest deal but it would be nice to have fewer reader conditionals in the code

timgilbert19:07:21

(Er, "normalized" meaning "same value on both platforms")

dnolen19:07:56

hrm I don’t know - we’ll think about that

timgilbert19:07:18

Cool. Would a ticket be helpful, or is that premature?

dnolen19:07:54

premature I would say at this point

timgilbert19:07:02

Ok, cool. Thanks!

yedi20:07:43

how do i check if a var is a function? this is what i tried:

app:cljs.user=> (type t)
#object[Function "function Function() { [native code] }"]

yedi20:07:57

idk how i'd convert that into a boolean check

yedi20:07:30

ah thanks, also: (= (type t) js/Function)

dnolen20:07:41

somebody add a Planck / Lumo bot to this channel already 🙂

anmonteiro20:07:11

could be a fun side project

mfikes20:07:23

But we humans are here 🙂

mfikes21:07:05

@timgilbert For portability, I’d consider (= ::s/invalid (s/conform int? "a"))

dnolen21:07:25

I have a significant amount of help these days 🙂

dnolen21:07:05

the features of the last post is mostly thanks to the hard work of @anmonteiro & @juhoteperi

mobileink21:07:39

correction: he is what machines wanna be when they grow up. simple_smile

mobileink21:07:22

incredibuulll community.

timgilbert21:07:51

Oh great idea @mfikes, thanks

dragoncube23:07:51

does someone have any “best practice” for deploying app with two versions, one compiled with all advanced optimizations and one with just simple optimizations? So, if any bugs happens you can ask people (customers, field team, whoever has access to env) to open “debug” version so you can get better idea if this due to advanced compilation or actual bug.

dragoncube23:07:53

also, do you package source maps for “production” build?

dragoncube23:07:03

pretty much what is your “debuggability” story for production builds

rgdelato23:07:29

with the new string requires, if I do something like (in Node):

(ns foo.core
  (:require ["fs" :as fs]))
...do I use it like (fs/readFileSync ,,,) or (.readFileSync fs ,,,) (or I guess (fs.readFileSync ,,,))?

anmonteiro23:07:23

or.. all of them!

anmonteiro23:07:46

@rgdelato all of those work 🙂