Fork me on GitHub
#clojurescript
<
2015-11-14
>
richiardiandrea00:11:01

Can someone suggest a good media query tool in either ClojureScript or Javascript (Cljsjs) ?

richiardiandrea01:11:11

found [cljsjs/enquire "2.1.2-0"]

nowprovision07:11:39

is there a better way of seperating out cljs deps when the clj server is in the same project (ref: https://github.com/nowprovision/webhookproxyweb/blob/master/project.clj) ?

martinklepsch10:11:43

@nowprovision: there no special syntax for that. Assuming you don't compile cljs in the server process I'd recommend using ’:scope "test"` so the cljs dependencies are not loaded for clj server

jaen11:11:56

Hm, I create a future with an API call in ring handler and then deref it once in the index view. Yet when I put printlns in it, they are output twice. Is that expected? I thought futures cache their evaluation?

jaen11:11:30

Ok, that's just Chrome requesting the page twice for some reason, nevermind.

moxaj17:11:07

Anyone here familiar with cljs.js/eval?

dnolen17:11:42

@moxaj: just ask your question simple_smile

moxaj17:11:18

@dnolen Well, I'm trying to evaluate a function, which references a var from another namespace, but it complains that it cannot find it.

dnolen17:11:09

@moxaj: right you need to provide a way to load those files

dnolen17:11:07

@moxaj: I would read over all the docstrings in the cljs.js namespace

moxaj17:11:25

@dnolen this is something specific to eval right? I don't think I messed up my imports, it works in clojure (most of the code resides in .cljc files)

dnolen17:11:11

@moxaj: it works in Clojure because Clojure is on the JVM and has cross platform IO facilities

dnolen17:11:14

JavaScript does not

dnolen17:11:21

so you must supply them

moxaj17:11:19

@dnolen alright, gonna check out the docs, thanks for the help!

moxaj18:11:20

@dnolen Now this is strange. First a little more context: I'm evaluating code in the browser, not on node (maybe it makes no difference). When evaluating, the console tells me "warning: no such namespace ..." and "warning: use of undeclared Var ...", but it still works! I have no idea what's happening 😀

jaen18:11:39

Hm, possibly you're still not resolving requires properly so the compiler can't tell whatever you're doing makes sense, but you use it properly so the generated code works? Something akin to how you can link C libraries without headers and it still works.

jaen18:11:55

Though I'm not really all that versed in self-hosted cljs

bhauman18:11:37

@moxaj: sounds like the source is compiled but you don't have any analysis information in your compilation environment.

moxaj18:11:27

@bhauman @jaen is this something I should be concerned about (performance-wise or otherwise)?

bhauman18:11:18

@moxaj: You need to make sure require works or you will be missing some major functionality.

jaen18:11:48

I don't think performance would be majorly affected, but as bhauman said compiler may not require some code you need and it will not work (though it just might as it did in this case)

jaen18:11:03

Also you might not be warned about misusing your code, since there's nothing to check during compilation

moxaj19:11:37

@bhauman as far as I can tell, my require-s work, the problem is that the evaluated function references namespace-qualified symbols from other namespaces, the ones the compiler complains about.

tony.kay19:11:23

@bhauman: Is there any way to let a devcard component use A tags with #? They cause devcards to navigate back to the "main menu"

bhauman19:11:12

@tony.kay: yeah having components that mess with push-state is not supported, it's a global concern

tony.kay19:11:28

ok...so no options I can pass to the UI startup

bhauman19:11:11

nope, but it seems an interesting way to solve this would be to have a component that you can wrap your components in that virtualizes routing calls

bhauman19:11:27

that way your examples are seperate

bhauman19:11:37

complete with location bar

tony.kay19:11:03

Good enough. Just wanted to make sure I wasn't missing an option. If I develop something to handle it I'll send it your way. Not critical at the moment.

bhauman19:11:26

Cool I think folks would be interested

johanatan21:11:19

@moxaj: 'Use of undeclared var...' can be ok if the var is eventually assigned before the code referencing it is actually invoked. (declare blah) where blah is the name of the var before the reference will remedy it. Otherwise, you can move the code assigning the var to earlier in the minified JS file (via specifying compile/concat order) or moving the actual logic higher in your own files if it is a var you control.

johanatan21:11:29

@moxaj: In fact, in my experience I've never had that warning actually point to a real issue at run time.

moxaj21:11:53

@johanatan The var has its value assigned even before the (eval ...) is evaluated, and I don't think I can do it anytime earlier

johanatan21:11:49

@moxaj: Are you sure? Did you try printing the value of the var directly before the eval?

johanatan21:11:52

Are you eval'ing a string or is this a macro? If the former, I am surprised there's any warnings at all

johanatan21:11:37

Yea, something else is going on then. There's no way ClojureScript is looking inside your string and giving warnings about its contents

jaen21:11:04

But I think it might not matter that the var is assigned before eval - I don't imagine self-hosted Clojurescript takes into account anything other than supplied sources during the analysis.

moxaj21:11:54

@jaen I agree. Maybe there's some way to tell the evaluator about the other namespaces - but for now I don't really care, because the code runs anyway

johanatan21:11:52

Hmm, yes, I used to get the warning a lot re: console.log (which is a pretty basic 'external dep' simple_smile )

jaen21:11:17

Well, I'm more of a correctness-first person, so I would want to figure it out first, lest it bite me in another corner case. But if it's good enough for you, then good ; d

moxaj21:11:34

@jaen i'll just have to set print-fn to a dev/null-like function and enable console printing later:grin:

moxaj21:11:52

@jaen whops, formatter ate the earmuffs

jaen21:11:21

I think you can backslash-escape that \printfn\

jaen21:11:26

Hm, or not xD

moxaj21:11:40

is this markdown btw?

jaen21:11:05

Just the basics, like quoted code blocks, bold, italics, blockquote

jaen21:11:13

I don't think lists or headings work

jaen21:11:20

Yeah, it's pretty handy at times P ;

moxaj21:11:33

By the way, what's the cljs equivalent of

intern
?

jaen21:11:05

I think there might be none, since Clojurescript doesn't have vars

jaen21:11:13

But I may be wrong

moxaj21:11:53

heh, I can eval the namespace-qualified symbol and it works, seems a little hackish though

johanatan22:11:16

Hi, does aset accept deep paths?

johanatan22:11:32

e.g., I want to set: this.txtInput.style.color to "red" for example

johanatan22:11:09

Do i need (this-as this (set! (.-color (.-style (.-txtEmail this) ... ?

johanatan22:11:41

[I of course want the rest of the styles in place to remain unchanged; i.e., so a merge rather than a swap/reset].

dnolen22:11:30

for big projects I suspect the results could be pretty dramatics for cold :none builds

juhoteperi23:11:17

I'm testing the largest project I have access to right now on my dual-core thinkpad

juhoteperi23:11:26

Will try on my 6-core i7 tomorrow

dnolen23:11:55

it’s pretty experimental very little in the way of error handling yet so will need to work on that.

dnolen23:11:13

but without it building Om Next dev cards takes 20-21 seconds on my Macbook

dnolen23:11:25

with it enabled 12-13 seconds

jaen23:11:59

That looks like a nice addition. Pity I don't have big enough project to compare it on ; /

dnolen23:11:38

@jaen even if it’s not big it will make a difference, i.e. a significant number of deps

jaen23:11:21

Let's see then...

jaen23:11:51

I have to build from source, right?

dnolen23:11:23

./script/build

jaen23:11:28

Yea, I know the drill, you just might have happened to put out a prerelease or something

dnolen23:11:50

@jaen this needs some basic tire kicking first simple_smile

juhoteperi23:11:42

I'm seeing decrease from 35s to 25s on this dated Thinkpad

dnolen23:11:56

@juhoteperi: that’s pretty good!

juhoteperi23:11:23

Also, I'm seeing some warnings from random namespaces which seem be different between runs

juhoteperi23:11:55

"Use of undeclared Var"

dnolen23:11:23

yeah those warnings will probably depend on libs using vars not properly required or macro magic stuff

dnolen23:11:37

I haven’t see anything like that on Clojure ClojureScript libs

dnolen23:11:45

which have very clean requires

dnolen23:11:54

but I saw similar warnings for Figwheel & Devcards

dnolen23:11:18

the approach used here is dead simple

dnolen23:11:39

agent count = 2 + the number of cores on the machine

dnolen23:11:50

all agents spin on a deque, getting the next thing

dnolen23:11:09

they don’t proceed until all parent nses have been compiled

dnolen23:11:59

this is necessary of course to make sure the analysis of the current ns is correct

juhoteperi23:11:28

Sounds the same as what e.g. Make is doing simple_smile

dnolen23:11:38

(there of course might be bug in the code I wrote, could use a review)

jaen23:11:08

Hm, I'm compiling through boot. So with 170 I get 17.78 seconds and with 178 I get two values, 11.55 seconds for compilation and 14.01 seconds for adding dependencies.

juhoteperi23:11:20

@dnolen: I didn't find any problems but I have two comments: - Instead of populating deque and input-set with doseq I think it would be possible to initialize them with inputs (LinkedBlockingDeque has a constructor taking in a Collection) - pollFirst has arity with timeout which could be useful instead of Thread/sleep. I'm not sure but I presume that this wouldn't sleep for full timeout if item becomes available.

dnolen23:11:34

@juhoteperi: the first thing sounds great

dnolen23:11:51

not sure about the second thing because the queue is never going to get more stuff

dnolen23:11:04

so all threads will spin on it like crazy while waiting for an important parent ns to finish

juhoteperi23:11:01

Oh, right, the sleep is for waiting on the dependecies of the ns.

dnolen23:11:21

@juhoteperi: also your patch is the gift that keeps on giving simple_smile

dnolen23:11:27

made this code really simple to write

dnolen23:11:05

@jaen sounds like some thing is messed up with your environment

dnolen23:11:19

if you’re getting 2 values you are using an older version of ClojureScript not master

jaen23:11:34

Hm, possibly, let me check deps tree

jaen23:11:23

Hmm, I only have 178 in the deps tree. I even added a global exclusion just to be sure. So I'm not sure what can be wrong. With 170 I have no line about "Add dependencies" thought.