Fork me on GitHub
#clojurescript
<
2016-11-16
>
juhoteperi00:11:26

@ag is it slower only when you edit the .cljc file or always?

juhoteperi00:11:59

Cljs compiler itself doesn't reload macro namespaces so build tools implement than themselves. Boot-cljs reloads changed clj/cljc namespaces used by Cljs code.

juhoteperi00:11:16

But that should only happen when there are changed clj/cljc files.

ag00:11:59

@juhoteperi it seemed to be slow the first time on the task run. Anyway. I decided to keep things separate, in .clj and .cljs files

juhoteperi00:11:26

First time the task runs is always slow.

juhoteperi00:11:58

Hmm, macro namespace could make that even slower. Did the cljc namespace depend on many other namespaces?

ag00:11:31

hmm, define “many”. how many is “many”?

juhoteperi00:11:05

Hmm, any, even one namespace which is slow to evaluate can make this slower

juhoteperi00:11:45

In case of macro namespaces, the dependency namespaces have to be loaded to Clojure environment

ag00:11:18

yeah, I guess. anyway… as I said: I think it wasn’t great idea in the first place… it’s totally fine to keep things in separate files although it’s technically is the same namespasce

juhoteperi00:11:33

I guess I use so few macros nowadays that it is possible that I wouldn't notice if there is a problem in boot-cljs

ag00:11:41

yeah macro-business in cljs is tricky

juhoteperi00:11:07

Yep, checked a few projects and no local macros. Some dependencies of course use macros.

anmonteiro09:11:56

@juhoteperi: FWIW the ClojureScript compiler now reloads macro namespaces in watch since 1.9.183: https://github.com/clojure/clojurescript/commit/2267a8e5e9607aff8c940fa372dbdb35816350ba

juhoteperi09:11:35

@anmonteiro Right, but build tools reimplement watch

anmonteiro09:11:43

Yeah, I'm not saying it's practical to support in tooling, just being pedantic if anyone is using cljs.build.api/watch

mitchelkuijpers11:11:51

@ag @mulchy >bulk of CIDER functionality does not work with cider-connect, you gotta jack-in Sorry, but that is not true. You can set the setting: cider-cljs-lein-repl to for example "(start-repl)” and then you can do cider-create-sibling-cljs-repl when you are connected to the clojure repl.

hwk14:11:24

I am using cljs.spec/assert

hwk14:11:45

when it fails, I need to catch the error (try ... (catch js/Error e ...))

hwk14:11:59

now, my question: how do I get an stack trace from "e" ?

hwk14:11:15

if I don't catch the exception, Chrome gives me a very detailed stack trace

hwk14:11:34

however, if I catch it -- I only get a basic error message -- but not the stack trace

thheller15:11:43

@hwk (.-stack e) but beware, those vary greatly depending on the browser

thheller15:11:49

and they are not source mapped

thheller15:11:55

so they are basically useless

thheller15:11:52

(also it is a string in chrome, not an array or so)

hwk16:11:52

thheller: thanks! yeah, I noticed that (1) if I dump them out in a [:pre ] in hiccup, they are NOT source mapped (showing lines in .js files) -- but if I dump them out to (.log js/console ...), the console does source map them for me; I'm guessing sourcemap info is *NOT easy to do inside cljs, and is handled by the browser?

thheller16:11:16

yeah source map is done by the devtools

thheller16:11:01

you can do it manually in the browser, but it is not going to be fun

hwk16:11:34

thheller: thanks for the explainations; yeah, I'll just use devtools

tom16:11:03

Running into an issue with testing clojurescript. I am using reagent with re-frame. I have excluded React altogether. However, when running lein doo to test, using karma chrome, I see it cannot find React. So I added them in :cljsbuild as a foreign lib. Is there a way to verify that the foreign lib is being loaded? It still claims Uncaught Error: js/React is missing

hwk16:11:49

tom: 1) isn't reagent built on top of React? how did you manage to eliminate it?

hwk16:11:00

2) I also don't understand why you appear to be (a) removing React and (b) trying to put it back in

hwk16:11:05

do you need a different version of React or something?

tom16:11:07

hwk You add it as an exclusion to Reagent in the :dependencies and then add blank namespaces for cljsjs.react and cljsjs.react.dom. It works well, especially since this is used in a bigger React project.

tom16:11:02

It works in the larger react project fine. It's just adding some tests for it where it's getting problematic.

hwk16:11:10

tom: I see. This is interesting but way beyond my pay level. Good luck though!

tom16:11:30

Yea it's kinky af

hwk16:11:02

Reagent is one of the most brilliant libraries I have used. r/atoms are awesome

tom16:11:31

it's great. re-frame builds on it nicely.

hwk16:11:25

never read re-frame, but read it's documentation while trying to figure out "how do I setup a canvas module inside react" and reframe docs is like "there are three levels of reagent components; reagent only teaches you ghe first level; we teach you the third, undocumented level for wriing your own components"

tom16:11:15

I only retain a paragraph of information at a time, so I read the docs but it didn't stick until I used it.

sophiago19:11:53

i tried asking this in the om channel so apologies for crossposting, but has anyone used goog.cssom? i'm finding myself in need of calling a css method and seems the best way would be to use addCssRule, but i'm unsure about the syntax for the parent sheet. for example, whether i can be like (goog.cssom/addCssRule (str "#" id) (str ...))

johanatan19:11:30

hi, under what conditions would the following return false for a javascript obj: (map? (js->clj obj)) ?

johanatan19:11:04

If I try to convert the object to a string in order to print it out, I get "Cannot convert object to primitive value"

johanatan19:11:25

But if I merely print it with (js/console.log obj) then I get a fairly innocuous looking map/obj representation printed out

johanatan19:11:01

by "innocuous looking" I mean precisely the following: { artist: 'Pink Floyd', label: { name: 'labelname' } }

johanatan19:11:12

my guess is that there are hidden properties or something on the obj which are preventing js->clj from fully converting it to a map (and .toString from converting it to a string)

kenny19:11:40

@johanatan Don't know what the problem is, but I suggest you enable "pause on exceptions" and walk the stack to figure out where the error is occurring in js->clj. This should hint at what the problem may be.

johanatan19:11:56

This is in nodejs

johanatan19:11:38

[and the debug story there as far as I am aware is "console.log" 🙂 ]

kenny19:11:37

Well, if that's true, that is awful.. 😞

kenny19:11:46

I suppose you could copy the js->clj code and add printlns everywhere to figure out where the problem occurs. Seems so archaic lol

johanatan19:11:22

ah, not a bad idea. 🙂 yes, definitely archaic but anything that works at this point

kenny19:11:48

I suggest you look into setting up node-inspector (or something similar). Would be a huge productivity boost! 🙂

kenny19:11:01

@johanatan If you are using Node 6.3 or above you could use Node's built-in inspector. See http://stackoverflow.com/a/39493551

kenny19:11:39

Caveat: I am not a Node expert.. These were just the first results on Google 🙂

johanatan19:11:44

@kenny oh, sweet! thx!

dnolen19:11:02

@sophiago that’s a good question for here - I would check the Google Closure API docs

dnolen19:11:07

seems like the answer is the first argument cannot be a string

sophiago19:11:25

@dnolen ah ok. i did look at that first thing

sophiago19:11:33

so you think something more like: (goog.cssom/addCssRule #id (str ...))

sophiago19:11:59

if i'm using it with elements generated by om?

dnolen19:11:30

you need to have a CSSStyleSheet instance in hand

dnolen19:11:46

perusing the API it looks like it’s all pretty manual

sophiago19:11:47

perhaps should use addCssText instead then?

dnolen19:11:22

that creates a new style element - not sure if that’s what you want

sophiago19:11:23

right, it's for manually writing stylesheets as essentially string literals

sophiago19:11:29

essentially, yes, because i'm styling individual elements generated by om

sophiago19:11:51

so i don't have a preexisting sheet in my style.css

sophiago19:11:40

and the only reason i thought of going this route is the need to call a css method and that seemed to not be working otherwise

sophiago19:11:53

matrix transforms apparently require that

sophiago19:11:17

i assume because it's done at hardware level. that's one reason why i'm not into css. rather opaque as to what's going on behind the scenes

dnolen19:11:02

@sophiago I’m confused - is there some reason you can’t just write a stylesheet? Or are you investigating whether you can avoid it?

sophiago19:11:42

i'm writing a function that needs to do a matrix transform on the fly and that requires calling a css method matrix(). i'm not aware of any way to interop that with cljs

sophiago19:11:13

does that make sense? you pass the selectors methods: http://www.w3schools.com/css/css3_2dtransforms.asp

sophiago20:11:27

so before i turned to goog.cssom my first attempt looked like this:

dnolen20:11:52

@sophiago can’t you just set an inline style to do what you want?

sophiago20:11:14

maybe i can do it inline and i'm just confused about syntax?

dnolen20:11:14

@sophiago that snippet isn’t clear - where are you setting the styles?

sophiago20:11:04

slider-factory is an om/factory created from a defui and then i'm setting the style in :transform, which requires the matrix method

sophiago20:11:41

and i get an error on that method calling it that way

sophiago20:11:56

which looks like: (matrix a, b, c, d, e, f)

dnolen20:11:05

@sophiago I’m confused - show me slider-factory

dnolen20:11:35

the matrix string looks wrong to me as well

sophiago20:11:55

right. the om stuff is standard. the matrix string is clearly worng

dnolen20:11:55

matrix(N, N, N,N, N, N)

sophiago20:11:17

oh, so you're saying pass it in as it appear in css?

dnolen20:11:31

slider isn’t using the matrix style

dnolen20:11:48

@sophiago absolutely - you must create valid CSS strings

sophiago20:11:59

well the thing is it's not a string, it's a method

sophiago20:11:14

hence my line of thinking

dnolen20:11:24

you might be confused by CSS terminology here 🙂

dnolen20:11:32

that’s just what they say - it’s not how it works

dnolen20:11:34

it all just strings

sophiago20:11:54

ah ok. just to be clear, i do not know css well and do not like it either 🙂

dnolen20:11:02

understandable

sophiago20:11:16

so i massively overcomplicated this

dnolen20:11:27

yeah it’s pretty easy

dnolen20:11:39

just add :style entry for the CSS property you want to set

dnolen20:11:45

and the value must be a valid CSS string

sophiago20:11:08

i didn't realize that either. so it needs to be in the defui for me to alter it later?

dnolen20:11:52

you can decide how you want it to change - but first idea would be via props, yes

sophiago20:11:16

right. i'm more just at proof of concept with this now. but that clears things up greatly. thanks! going to try it now 🙂

johanatan20:11:36

^^ that is the object

dnolen20:11:47

@johanatan sorry I do not, nor do I have time to look at it right now

dnolen20:11:09

if you can make something minimal - then file an issue

manutter5120:11:34

@johanatan what do you get if you do (.log js/console (js->clj obj))?

sophiago21:11:16

@dnolen thanks again, everything is working. sort of...my bias against css is confirmed by their inability to use transform matrices in standard format 😛

sophiago21:11:35

"matrix(scaleX(),skewY(),skewX(),scaleY(),translateX(),translateY())" <= who thought this was a good idea? 🤕🔨

sophiago21:11:58

easy fix tho

dnolen21:11:11

long live the web!

kenny22:11:31

From Om.Next docs: > Previously Om attempted to mitigate deep coupling to state via the cursor abstraction. Unfortunately, cursors brought problem of their own. Is there an article/blog post somewhere detailing the problems people found with cursors? Was it asymmetrical read/writes? (asking in #clojurescript because this feels like more of a general cursor question than an Om specific one)

anmonteiro22:11:23

@kenny I think David touched on those at his EuroClojure talk last year (2015)

kenny22:11:02

Any idea where exactly?

anmonteiro22:11:14

I'd have to watch it again 🙂

kenny22:11:34

Will watch the whole thing then.. 🙂

markx22:11:54

Could you recommend me a framework or a game engine for making web games?

kenny23:11:31

Hmm.. He does mention it at 6:00 in the video, but it's not totally clear what the problem is. He says the API is around collection access to which I inferred that he means it does not generalize to other data stores (e.g. Datascript). But it seems like if you have a "universal" cursor where an arbitrary lens can be applied to an arbitrary data structure then you do not have that problem.

kenny23:11:35

@dnolen Could you clarify? I just want to understand the problem that was hit with cursors.