Fork me on GitHub
#clojurescript
<
2016-04-19
>
darwin00:04:16

@naomarik: compile it with :pseudo-names true and :pretty-print true, this should tell you more

naomarik00:04:46

thanks darwin, will try

naomarik00:04:18

huge lesson in using safari's debugger 😉

andrewboltachev02:04:22

Hi. Is there any tool that allows running (compiling and auto-reloading) (1) Node.js on the server (2) ClojureScript with REPL on client (for web development)?

andrewboltachev02:04:16

Or, would I need to run two compilers anyway (in separate windows) to achieve this?

kspear03:04:51

I'm having issues when I attempt to compile-str the contents of a file containing cljs and dump the output to a js file. When I attempt to run my output .js file with node, I get "cljs is not defined" if I reference any fn from the cljs.core namespace. Is there a way to have the cljs.core ns compiled into the output js with compile-str, or do I need to take a different approach?

slester04:04:52

Someone recommended to me a library to work with secretary to push state into the history bar... any idea what that was? 😞

slester04:04:28

Never mind, just found it: pushy! Thanks.

slester04:04:14

Well, I'm confused now, because that doesn't work either.

amonks04:04:49

@slester: what’s the issue?

slester04:04:07

So so many issues. 😞 So, I have secretary working in that (dispatch! "/example") will take me to the correct page, but it won't update the URL bar -- it stays http://localhost:3449

slester05:04:23

I have that hook in there, as I was following a guide.

slester05:04:38

I'd also like to figure out how to get http://localhost:3449/example working, but that can wait 😄

amonks05:04:48

I’m pretty sure secretary doesn’t do that, I’m using secretary with https://github.com/venantius/accountant and I believe accountant is handling the url bar update

amonks05:04:09

link the guide you’re following?

roberto05:04:24

@amonks is right, secretary doesn’t do that

roberto05:04:34

you can also try pushy + secretary

slester05:04:35

I don't understand the purpose of that 'hook-browser-navigation' or of 'pushy'

slester05:04:43

pushy didn't do anything I'm afraid

slester05:04:01

well, following its guide didn't help at all

roberto05:04:12

I don’t think that will change the navigation url

roberto05:04:32

it will only route from navigation path to secretary route

roberto05:04:35

but not the other way around

amonks05:04:54

yeah it looks that way ^

roberto05:04:57

it is a source of confusion for people starting with secretary

roberto05:04:07

yeah, it sucks

slester05:04:10

it seems like it's half of a library

amonks05:04:19

accountant does what you’re looking for

slester05:04:25

I mean, I get unix-philosophy does-one-thing but... hm

slester05:04:30

@amonks trying it now 😄

slester05:04:33

thanks for the tip

slester05:04:40

it needs to be linked or something IMHO on the secretary page

amonks05:04:51

here’s a fairly small project where it works

amonks05:04:23

someone else might have a more minimal example

slester05:04:25

still doesn't seem to be doing anything

slester05:04:28

(accountant/configure-navigation! {:nav-handler (fn [path] (sec/dispatch! path))
                                   :path-exists? (fn [path] (sec/dispatch! path))})

amonks05:04:06

then use (accountant/navigate! "/foo/bar/baz")

amonks05:04:10

when you want to navigate to a page

amonks05:04:28

or it’ll listen for clicks on <a> tags

slester05:04:54

oh, gotcha, it's not listening on secretary, whoops, that was pushy I think

roberto05:04:55

@slester you need to change whatever you want to trigger the change to use accountant instead of secretary

roberto05:04:34

I imagine that your onclick event is still using sec/dispatch!, instead change it to use the the function @amonks mentioned

roberto05:04:49

basically, accountant will be a sort of proxy for secretary

roberto05:04:43

I’m kind of liking that approach, didn’t know about accountant. I can see how it can make it easier to test other routing libraries

roberto05:04:59

because the dispatch calls aren’t scattered throughout the code

amonks05:04:26

I like it.

slester05:04:21

AHHH. It's GLORIOUS. ❤️ Thank you so much!

slester05:04:30

I'm going to put in a PR to add a link for that in secretary's readme

slester05:04:21

well, now clicking anything that isn't a link sends me to / ... so that's weird, but still progress!

urbanslug06:04:00

@amonks: and these many core.clj* don’t conflict?

amonks06:04:48

are you in lein or boot? I’ll link an example

amonks06:04:33

look at that ^

urbanslug06:04:58

I wish there were less demos and more projects though 0.o not complaining I still appreciate it.

amonks06:04:28

yeah, I feel that too.

amonks06:04:08

or maybe more demos and more projects 😉

urbanslug06:04:45

More is good

bvulpes06:04:47

amonks: holy doodle how did you do that animation on your homepage

bvulpes06:04:55

dood that's pretty neat.

bvulpes06:04:09

higher dimensional shit always gets me going.

amonks06:04:38

full credit to Kevin Zweerink for that one

bvulpes06:04:43

myeah, i found it

bvulpes07:04:19

> once the mechanics for extruding to 3D have been established, extruding to 4D is a relatively simple proposition

martinklepsch08:04:48

@naomarik: when encountering issues with advanced and other things are loaded on the page :output-wrapper might help

pesterhazy09:04:58

Does anyone know a web-based EDN/clojure data structure viewer? Basically pretty print in a browser with the ability to collapse/expand nested stuctures?

jimmy10:04:47

hi guys, how to convert uuid string to uuid instance ( with tag ) in cljs ?

jimmy10:04:18

@pesterhazy: cljs dev-tools ?

pesterhazy10:04:19

@nxqd: hmm I'd prefer not to tie it to chrome

biscuitpants11:04:46

Any good books to read up on to start with programming UI?

danielcompton11:04:39

@nxqd: you can use uuid in ClojureScript now

kspear14:04:28

Hoping maybe someone can help me with this: https://clojurians.slack.com/archives/clojurescript/p1461035091000281 any takers? simple_smile not quite sure how to get result I'm looking for this self hosted cljs problem. For the moment I'm "working around" it by injecting a few lines of JS at the top of my output file that load the compiled js dependencies produced with cljsbuild (`:optimizations :none`) of a stub cljs project.

plexus14:04:52

is there a way to check inside a macro whether it's being used in Clojure or ClojureScript?

mccraigmccraig14:04:25

@plexus: you can use a reader-conditional to yield different values in clj/cljs - http://clojure.org/reference/reader#_reader_conditionals

plexus14:04:59

yeah but does that work? macros are always expanded by Clojure...

plexus14:04:13

so at macro expansion time you would be in a Clojure context

mccraigmccraig14:04:32

oh, yeah, oops - not thinking hard enough

plexus14:04:52

I'm looking if I can solve this long-standing issue https://github.com/jaycfields/expectations/issues/54

mccraigmccraig15:04:14

hacky maybe, but is there some cljs-compiler state you can examine ?

plexus15:04:38

possibly...

grounded_sage15:04:32

I'm curious when would you choose to use say an atom or r/ratom over datascript and vice versa.

naomarik15:04:29

@kspear did you try using export on the functions you want to appear outside? this might help http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html

anmonteiro15:04:22

an alternative way to check for CLJS / CLJ

anmonteiro15:04:31

I’ve had luck with such approach

mrg15:04:45

Any ideas why simply requiring clojure.repl.browser would throw me a "SyntaxError: invalid range in character class" at runtime?

mrg15:04:59

on "goog.i18n.bidi.rtlCharReg_ = new RegExp("[" + goog.i18n.bidi.rtlChars_ + "]");"

mrg16:04:43

Seems to be a 1.8 issue.. it looks like it's working in 1.7

plexus16:04:31

@anmonteiro: thanks, it seems that's exactly what I need

fabrao17:04:43

Hello all, I´ve been reading lots of informations about Circular Dependency and I realy don´t know if there is a clean solution about it. So, in my clojurescript project, do I have to put all the UI in the same namespace file?

madvas17:04:00

Does anyone know if externs.js file, (when :advanced optimizations) have impact on dead code removal or is it just for not renaming symbols?

dnolen17:04:01

@madvas: I believe just renaming. It should be easy to put together a very simple test though.

thebeatcoder17:04:31

Hello, guys! I'm new to ClojureScript but now I'm JS dev and familiar with functional programming a little bit. So, could you recommend some materials to get into ClojureScript. Thank in advance!

zentrope17:04:30

@bhauman: When I “lein repl” and use the sidecar api to start-figwheel, it doesn’t seem to pick up any of my config. I’m not merging from profiles: it’s all there at the top level.

bhauman18:04:33

That's interesting. What happens when you run lein figwheel?

zentrope18:04:04

I get a repl and everything works great.

zentrope18:04:17

I can get the “old school” nrepl stuff working (from the wiki).

bhauman18:04:52

Hey I'm out for a walk I'll get back to you in a bit

zentrope18:04:56

Surely, openjdk 8 on osx isn’t the problem. ;)

kspear18:04:45

@naomarik: I'll give that a look. Thanks 😃

spinningtopsofdoom18:04:00

Clojure and ClojureScript overlap ~90 - 95% and really only differ on host (JVM vs. JavaScript) and low level details (protocols and types)

amashi18:04:02

Yeah, it's kind of nice how much is the same between clojure and clojurescript- a big selling point, IMHO.

amashi18:04:46

Quite a while back I wrote some web stuff with the server in CL, and the client js generated with a cl lib called parenscript, and it was in some ways a very nice system, but... clojurescript does a much better job of treating js as a compile target.

bhauman18:04:37

@zentrope: so you are saying that when you run lein repl and then run (start-figwheel!) it doesn't pick up your config?

zentrope18:04:12

Yes. After (use 'figwheel-sidecar.repl-api).

zentrope18:04:20

I had a ~(hostname) thing in there, so maybe that’s it.

bhauman18:04:33

@zentrope: try (figwheel-sidecar.config/fetch-config)

bhauman18:04:44

and see what it returns

bhauman18:04:05

yeah that hostname thing is probably causing problems

zentrope18:04:10

{:figwheel-options nil, :all-builds [], :build-ids []}

bhauman18:04:24

yep not picking anything up

zentrope18:04:26

I removed those, still no config.

zentrope18:04:46

I might just have to punt and go with a user.clj with explicit config.

bhauman18:04:52

do you have a figwheel.edn in your directory?

bhauman18:04:47

well try (.exists (io/file "project.clj"))

bhauman18:04:16

and then try this (into {} (map vec (partition 2 (drop 3 (read-string (slurp "project.clj"))))))

bhauman18:04:42

I bet that throws an exception ...

zentrope18:04:01

Exists is “true”.

bhauman18:04:19

Yeah I'm eating the exception so that is a problem

zentrope18:04:24

the “into” returns {}.

zentrope18:04:35

What if “defproject” isn’t the first form in the file?

bhauman18:04:44

oh that would do it

zentrope18:04:45

I bet that’s it.

bhauman18:04:14

what is the first form in the file?

zentrope18:04:29

I’ve got a couple of functions in there to calculate the hostname so I can reach my websocket app from other machines without explicit setting (in a dev context).

bhauman18:04:41

oh that makes sense

zentrope18:04:53

Well! At least there’s an explanation, and super simple!

bhauman18:04:11

there is a :server-hostname now

bhauman18:04:20

in the next release

zentrope18:04:48

Yeah, but I don’t want to have to set the hostname explicitly for every machine I might run the software on in a dev context.

bhauman18:04:33

no it doesn't work like that

zentrope18:04:10

Ah, okay. Hm. I also set a closure-define so that my own app (which uses websockets) can find a host.

zentrope18:04:36

Regardless, if I remove those extra forms, figwheel works as documented. ;)

bhauman18:04:55

reading defproject raw is definitely confusing but including leiningen core into the running application is not so great either.

zentrope18:04:19

But then those functions don’t get evaluated and interpolated.

bhauman18:04:19

basically reading defproject raw is a convenience from the REPL. since the repl lives in a different process from leiningen

zentrope18:04:25

In the #C0617A8PQ channel @rmuslimov is using user.clj to launch a dev version of figwheel, then keeps project.clj as strictly a way to build for production.

bhauman18:04:46

you can also just use a figwheel.edn

bhauman18:04:05

without interpretation

zentrope18:04:22

Yeah, if you wanted to fix it, you’d just have to read all the forms, then only pick out the one starting with defproject, I guess obviously enough. ;)

bhauman18:04:28

but the user.clj is the best way to go as far as I know

zentrope18:04:38

Maybe it’s time to read the readme again!

bhauman18:04:30

the user.clj method is the best I'm thinking about having the template generate it and a piggieback cider connection

zentrope18:04:33

figwheel.edn: Of course, I have the same issue, needing to pass the hostname into the running app so it can find its web-socket server host.

bhauman18:04:54

but in the user.clj you can execute code no problem

zentrope18:04:34

I like the separation of project.clj for a good build, and user.clj for all the messy dev stuff. Makes both easier to read.

bhauman18:04:53

the user.clj is the best solution because as your app grows you dev requirements will out grow a declarative approach

bhauman18:04:08

and code will always win the day at that point

bhauman18:04:17

as evidenced

rmuslimov18:04:28

@bhauman: this is really good explanation why, thanks

mrg18:04:30

has anyone managed to get a browser repl on cordova working?

madvas18:04:09

Guys, is it normal, when I just require some cljsjs library in some namespace, don’t use any of its methods, and compiler still includes whole js file minimized into final app.js. It doesn’t do any dead code removal. (when :advanced optimisations)

dnolen19:04:16

advanced optimization is only for Closure compatible code

madvas19:04:08

@dnolen: aha okay thanks David!

fabrao20:04:35

If I have an atom with vector like (def a (atom {:g [["A" 90]["B" 10]]})) how do I update :g with new vector?

numberq20:04:25

(swap! a assoc :g new-vec)

fabrao20:04:57

@numberq: Thanks a lot, it worked

numberq20:04:39

No problem! I use https://clojuredocs.org/ for a lot of my own questions like that, searching atom will give you lots of examples and leads to the swap! page too.

fabrao20:04:11

I looked there but no example about setting new vector, sorry about that

lwhorton20:04:38

this might be a really dumb question, but does https://github.com/dakrone/clj-http support cljs?

lwhorton20:04:01

I see no indication of such in the http://read.me, but it seems to be the defacto standard of http libs for clj

amonks21:04:36

@lwhorton: no it does not

rmuslimov21:04:26

ok, it’s not version of that library, but it looks like it follows convensions from clj-http

amonks21:04:07

sorta, it returns channels rather than response maps

amonks21:04:05

but the api is fairly similar otherwise

borkdude21:04:23

I like cljs-http

lwhorton21:04:26

i’ve been using https://github.com/JulianBirch/cljs-ajax because it provides :interceptors out of the box

amonks21:04:15

what pushes you towards clj-http?

amonks21:04:17

if anything

yatesj921:04:46

@numberq: What if you just want to update one field or add to the atom above and not replace it?

amonks21:04:58

isn’t that what you did above? updated the :g field?

loganmhb21:04:05

@yatesj9: when you’re operating on the value in an atom, you can do whatever to it you’d do to the same value outside an atom

loganmhb21:04:30

so if it’s a map, you can (swap! a update :key f arg)

yatesj921:04:33

yes just found it, also assoc-in worked for my nested stuff.

cnilliams21:04:08

hello, how do I create an issue/pull-request for a specific docs page (and my subtle implication is why is there no link to the source on the docs page)? Example: http://clojure.org/reference/atoms

cnilliams21:04:47

Crap I'm in the wrong channel, sorry

lwhorton22:04:15

@amonks: not much, was just browsing around. cljs-ajax is fine just slightly confusing in some edge cases, and some of the docs aren’t terribly helpful.

bvulpes22:04:05

lwhorton: fwiw cljs-ajax failed me miserably on file uploads

bvulpes22:04:19

ended up with a lightweight homegrown wrapper around goog.xhrio