Fork me on GitHub
#clojurescript
<
2015-12-04
>
tolitius00:12:45

@mfikes: can't seem to call that ns-interns macro with cljs-bootstrap: https://gist.github.com/tolitius/c17b2d4a98eabb591926 (neither via cljs.js nor via replumb/read-eval-call), but I maybe missing something. I see that *load-macros* is true by default

mfikes00:12:37

@tolitius: In other words, your (def foo 42) is being done in “regular” ClojureScript, but then you are passing an empty compiler state to cljs.js.

brw31400:12:26

hi, i started working on the om tutorial https://github.com/omcljs/om/wiki/Basic-Tutorial, its up and running, but the figwheel repl doesn't come up after i've refreshed the browser, thanks

tolitius01:12:18

@mfikes: so that is why it's an atom simple_smile thanks a lot, makes sense!

tesseract01:12:09

how ready is om next to be used in production?

brw31401:12:06

Figwheel: trying to open cljs reload socket socket.js:62 WebSocket connection to '<ws://localhost:5060/figwheel-ws/dev>' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

mfikes01:12:28

@tolitius: Yeah. I suppose you can use cljs.js like that in a regular ClojureScript REPL, but in a deployment scenario you are dealing only with the state atom, essentially. If you need to load analysis metadata for stuff that is compiled and ships with your app, I suspect you can (it has been a little while since I’ve looked at that code).

tolitius01:12:25

@mfikes: did not occur to me how the pieces are used first time I looked at it, but it is coming together simple_smile

tolitius01:12:05

@mfikes: yea, I believe meta/vary/alter! are supported, but will find out

mfikes01:12:08

@tolitius: It appears they all work in Planck (a pure bootstrapped env), FWIW.

tolitius01:12:34

@mfikes: nice, thanks for checking

dnolen02:12:06

@tesseract: there is an #C06DT2YSY specific channel. Answer not quite, but we’re working steadily towards beta

dnolen02:12:20

people are building out production systems with the knowledge that beta is near

dnolen02:12:48

@brw314: you also might want to direct your questions to #C06DT2YSY

eyelidlessness02:12:17

is there a way to interact with clojure/jvm from the figwheel repl? or for figwheel watchers to produce output to that repl?

eyelidlessness02:12:49

the only way i've found to produce output is by throwing an exception

chuong06:12:47

Could you please let me know what is this error trying to say?

chuong06:12:50

it may be raise from below go block. (go (<! loaded-channel)...)

kneiva07:12:18

Why do I get “Uncaught TypeError: Cannot read property 'appendChild' of null” when trying (defonce conn (repl/connect "http://localhost:9000/repl”)) ? I’m running ring/compojure to serve HTML and I have started ClojureScript REPL with "lein trampoline cljsbuild repl-listen"

Tim08:12:57

are macros impossible to implement in javascript?

Tim08:12:15

why do they have to get compiled from the jvm?

rm08:12:13

@tmtwd: because of google-closure compiler. It removes everything that is not used

jbaiter09:12:42

is there a way to iterate through my project's namespaces in clojurescript?

jbaiter09:12:44

it doesn't have to be at runtime, i just want to build a tree of my namespace and a given value that each of them provides

jbaiter09:12:31

currently i'm requiring them individually and building the tree by hand, but this is going to get pretty tedious as the project grows

jbaiter09:12:41

to be a bit more concrete, say I have three namespaces 'foo.one', 'foo.two', 'foo.bar.one' and each of these have an 'info' symbol. I want a map {:foo {:one foo.one/info :two foo.two/info} :bar {:one foo.bar.one/info}}

jaen09:12:54

I can't know for sure since I never tried, but you could see if the analyzer API is available during macroexpansion - https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/analyzer/api.clj#L152-L158

jaen09:12:04

I don't know if it is though.

jbaiter09:12:08

thanks, I will look into that simple_smile

jbaiter09:12:19

meh, no such namespace 😕

jaen09:12:29

You tried it in a clj file, right? Then I guess tough luck. Unless someone more experienced with that comes along and has a brighter idea.

jbaiter09:12:49

yep, a clj file that I load with :require-macros

jbaiter09:12:38

grepping around on github, there seem to be people doing something similar with all-ns in clojurescript, e.g. https://github.com/darwin/plastic/blob/7c81a4fcc0bb53c25e1c1bbe5d41e23913ddbfcd/src/test/plastic/test/karma.clj

jbaiter09:12:27

i'm afraid that's a bit too advanced for day #3 of using clojure/cljs .)

jaen09:12:37

Yeah, I imagined it would work like that, not sure why it doesn't. But then again I never tried it in practice, so there might be something else you need to do I'm unaware of.

jbaiter10:12:43

hah, had a mistake in my macro... i syntax-quoted the outer form and thought I'd deleted the backtick. turns out there was some dust on my screen over that exact position :3

jbaiter10:12:42

wow, that is really neat ❤️ that's got to be the easiest way of metaprogramming i've ever done. doing that with python or java would have taken dozens of lines of code

jaen10:12:00

Haha, glad it's working then

jbaiter10:12:30

Btw, is there a way to see the expanded macros in clojurescript?

jbaiter10:12:21

I can only see the cljs with macros and the generated js in the out directory

trancehime10:12:58

Hey, @jaen, do you remember that gist you sent me

jaen10:12:57

@trancehime: I dunno, what was it about?

trancehime10:12:21

containing data from an atom which has vector

jaen10:12:35

@jbaiter: I guess you could just use the usual Clojure macroexpand since it's Clojure code.

trancehime10:12:25

what is .. in [new-value (.. e -target -value)]

trancehime10:12:36

i glossed over that last time

trancehime10:12:27

it's probably a reference to something but not sure what

jaen10:12:46

You know what (.-property object) does?

trancehime10:12:23

interop with js to get a property of an object? iirc?

jaen10:12:41

So .. macro is another layer of syntax sugar over it

trancehime10:12:57

oh .. is a macro

jaen10:12:05

It just expands to (.-value (.-target e))

jaen10:12:10

So you don't have to nest too much

jaen10:12:23

I think you can do even fancier things, like (.. e (function arg) -property-on-result) which should be eqivalent to e.function(arg).property-on-result

jaen10:12:29

But Id' have to check it in repl to be sure

trancehime10:12:58

Every element in a seq should have a unique :key wat

trancehime10:12:57

but.. pretty sure there is

trancehime10:12:21

oh wait the keys are like "this" not like :this

jaen10:12:36

What it means is

jaen10:12:45

If you have a dynamic list of children react has an optimisation to reuse existing DOM to make the updates faster

jaen10:12:03

You can tag each component with a unique (in the scope of a list) key to make use of that

jaen10:12:18

In the example from gist it would look like this

jaen10:12:07

(fn [idx {:keys [name min pos points]}]
  ^{:key "your-key-here"}
  [:tr ...])

jaen10:12:29

Where ^{} thing means adding Clojure metadata on the vector.

jaen10:12:42

Reagent uses the metadata to set the React keys on components.

trancehime10:12:46

yeah, i did ^{ } for some other stuff

jaen10:12:47

In this case something like (str "score-row-" idx)would be a good key, I guess.

jaen10:12:58

Unless you have some server-based id, then use that instead, I guess.

trancehime10:12:06

my problem is my data is keyed {"like" "this"} so doing it your way makes the thing behave weird even if I have server-based id

trancehime10:12:56

it makes it believe all the children have "id" which makes flattenChildren throw a warning

trancehime10:12:37

So far I haven't run into any problems until now...

jaen10:12:05

Hmm, can you show the code?

jaen10:12:44

That should not happen I think

trancehime11:12:04

derefing the atom gives me a vector of data which each element looks like this: {"end_level" 18, "schedule_game_detail_id" 157356, "id" 760501, "deaths" 1, "win" nil, "kills" 1, "player_name" "Huni", "schedule_game_id" 78749, "assists" 1}

jaen11:12:05

> Huni Hehe.

jaen11:12:17

That looks legit, let me think

jaen11:12:51

In the mean time you might appreciate this:

(defn transform-keys
  "Recursively transforms all map keys from strings to with given function."
  [m f]

  (walk/postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m))

(defn api->keyword-key [[key value]]
    [(keyword (str/dasherize (name key))) value])
and then you can just do (reset! local-match-state (transform-keys response api->keyword-key)) and get sensible keys like :player-name.

jaen11:12:08

But yeah, I think I misunderstood you when you said "oh wait the keys are like "this" not like :this", I thought you were referring to the metadata map.

jaen11:12:31

In that case you probably were right - you're using :keys instead of :strs in the destructuring

jaen11:12:56

So your id is nil each time, because you indeg by :id not "id" and all rows end up being mapped to the same single row.

jaen11:12:23

I suggest you try the code I've pasted above so you can get nice, dasherized keywords keys instead

jaen11:12:07

(`walk` is clojure.walk)

trancehime11:12:01

@jaen thanks, I will try that when I can. Right now I have to take care of some chores now that I'm back home. And my sister is still sick.

jaen11:12:29

Sure, feel free to ping me how it worked out.

mfikes14:12:47

If namespace foo.core depends upon bar.core (via a :require and a fn call), and I change bar.core’s on-disk implementation, should I see evidence of those changes if I do (require ‘foo.core :reload-all)? (Say by calling a fn in foo.core that then calls a revised fn in bar.core?)

dnolen14:12:14

:reload-all effectively forgets anything that has been loaded

mfikes14:12:18

@dnolen: Cool. I think I may write a minimal ticket then. (Not working for me for a very simple case with script/noderepljs.)

dnolen14:12:47

@mfikes: whether it works or doesn’t work is REPL dependent

dnolen14:12:06

and all of them manage this by tracking the loaded set in the JS environment via Google Closure

dnolen14:12:15

goog.dependencies_ specfically

dnolen14:12:24

sometimes this breaks because GCL changes the details

wildermuthn14:12:30

gmorning, Clojurists! Can anyone pointout resources for debugging go loop bugs via sourcemap in browser, or if there’s an issue already in progress on it?

mfikes14:12:53

@dnolen: Ahh… I think I see stuff you did specifically for the browser REPL for :reload-all. I’ll start there then. (I want to make it work in Ambly.)

dnolen14:12:00

@wildermuthn: nobody has ever picked up that problem

dnolen14:12:10

great thing for somebody in the community to work on

wildermuthn14:12:33

I’d be happy to dig in with a little pointing in the right direction

wildermuthn14:12:53

Should I start with sourcemaps? Learning how that works?

dnolen14:12:02

@wildermuthn: nothing to do with source maps at all

dnolen14:12:27

cljs.core.async needs to be fixed to use tools.analyzer a la clojure.core.async

dnolen14:12:05

this work has never been done

wildermuthn14:12:07

Currently, it uses something else, or just uses tools.analyzer differently?

dnolen14:12:16

cljs.core.async still uses a buggy hand rolled analyzer

dnolen14:12:12

@wildermuthn: I don’t have any more pointers to give you

wildermuthn14:12:22

Ok, thanks for pointing the right direction

dnolen14:12:25

you’ll have to poke around, the person to talk to is Timothy Baldridge

niwinz16:12:59

Hi, I'm found some trouble when trying compile some example code with :advanced/:simple compilation modes but I'm always getting this error: No implementation of method: :-find-sources of protocol: #'cljs.closure/Compilable found for class: nil, the same configuration but changing the :optimizations to :none everything works correctly.

Alex Miller (Clojure team)16:12:24

^^ would love to see your responses! thanks...

martinklepsch16:12:31

@alexmiller: just FYI, when I press next on page 2 on an iPad I get back to page 1.

dnolen16:12:53

@martinklepsch: that happened to me too, I had to go back and click next again \cc @alexmiller

monjohn16:12:54

@alexmiller: Page 2 answers didn’t save for me.

dnolen16:12:03

@alexmiller: I filled it out!

martinklepsch16:12:11

@dnolen: It did that for me multiple times, I'll try again later with proper computer

spinningtopsofdoom16:12:01

I got sent back to page 2 as well, from my laptop

Alex Miller (Clojure team)16:12:12

well I stopped changing it so if that's the problem it will be fixed!

mattg17:12:45

Wait, so changing values in place can lead to problems? Who would have figured! 😉

Alex Miller (Clojure team)17:12:34

well my changes were additive, so there was no reason they needed to force a re-do :)

martinklepsch17:12:04

Worked on first try with laptop

niwinz17:12:01

@martinklepsch: I restored my old build.boot file for some of my projects and I can confirm that now the speed is much much better in almost all tasks.

richiardiandrea17:12:42

@dnolen @mfikes Would it make sense to open a cljs-bootstrap Slack channel?

dnolen17:12:04

@richiardiandrea: I don’t think so

dnolen17:12:24

unless it’s about people with various bootstrap projects that want to chat

dnolen17:12:36

actual bootstrap questions should be here or in #C07UQ678E

jaen17:12:32

TIL there's such a thing as #C07UQ678E.

richiardiandrea17:12:46

@dnolen yes I was more thinking about projects

richiardiandrea17:12:44

Maybe with a different name

dnolen17:12:45

@richiardiandrea: yes that makes sense to me

richiardiandrea17:12:40

Ok then, I will try to come out with a better name, and wait for @mfikes opinion as well

mfikes17:12:14

Sometimes I’m a little bit concerned if we get off into the weeds about bootstrapped stuff. But, it is a part of ClojureScript proper now.

mfikes17:12:39

We could end up with too many channels if we aren’t careful simple_smile

richiardiandrea17:12:51

Well on the official wiki there are I think ten bootstrapped project in total, I just was thinking that it might be useful as a point of reference

richiardiandrea17:12:22

But again, the community opinion counts more and that's why I was asking :)

mfikes17:12:49

I was starting to think we might need another channel, but I hadn’t reached that level of pain. simple_smile

dnolen17:12:03

@mfikes I fine with people talking about it, it’s a very useful thing for people who are experienced with ClojureScript

dnolen17:12:16

some people seem to want to jump into the deep end, but there’s not really much that can be done about that

dnolen17:12:53

but a room for people who maintain bootstrap projects might make some sense

dnolen17:12:09

since that discussion is more focused on sharing ideas, approaches to building generic stuff

richiardiandrea18:12:15

Yes that's true, and ease the pain for us as well, for instance today I wanted to check how it ended up with ns-resolve and I had to scroll up quite a bit. Let's keep it under the radar, if questions increase a bit, we will create it I propose...

jaen18:12:10

Hm, this reminds me of a random idea I've had. I've re-played Ruby Warrior recently and thought it's a pretty cool way to introduce people to a programming language. I figured doing something like Champion of Clojure would be awesome and with bootstrapped Clojurescript it would actually also be possible.

richiardiandrea18:12:06

Yes analyzing code and comparing it to (optimal) solutions was something I was thinking of for http://clojurescript.io, then I went for something simpler...

jaen19:12:40

Heh, playing Ruby Warrior on intermediate made me appreciate how Clojurescript is a first-class implementation. Ruby Warrior is (I assume) using Opal and some common idioms don't Just Work™ (nothing against Opal guys though, I can imagine what a pain implementing Ruby must be with it's schizophrenic non-spec).

dfcarpenter19:12:03

Hey everyone im trying to check a url and having problems getting a window function to work. Any ideas? (re-seq #"/#/login$" (.href js/window.location))

noonian19:12:40

you need (.-href js/window.location)

noonian19:12:03

(.href …) would be trying to call that function with no args

dnolen20:12:11

@cfleming: any reason when I run a ClojureScript task or REPL from Cursive that I get a target directory with a bunch of stuff in it?

dnolen20:12:05

this creates lots of annoying problems since target/classes is often on the classpath implicitly