Fork me on GitHub
#beginners
<
2018-04-10
>
seancorfield00:04:07

(this is yet another case where I would just caution beginners to completely avoid ClojureScript until they're really comfortable with Clojure!)

justinlee00:04:31

@seancorfield but i don’t need clojure!

seancorfield00:04:48

@lee.justin.m You do if you're using macros 🙂 🙂

justinlee00:04:56

damn you got me there lol

seancorfield00:04:11

Well, there's self-hosted cljs right? I have no idea what state that is in...

mfikes02:04:43

Macros work fine in self-hosted. I submit the port of core.async a couple years back as evidence 🙂

justinlee00:04:11

i guess that’s why i haven’t written a single one yet

justinlee00:04:00

there is but you still have to do the same macro shenanigans even though the macros are actually cljs, from what i’ve read

lgessler00:04:50

confirming that that was the issue--i moved the macro into a clj file with an identical ns and used require-macros from the cljs file

lgessler00:04:56

thanks for the help all 🙂

lgessler00:04:49

I'll continue using cljs without a solid knowledge of clojure at my own risk... sometimes there's not enough time for best practices eh?

brunobraga02:04:34

hey guys, I am trying to send out a enviroment variable to my clojure app, but it wont recognize it..can anyone see a problem with the following approach? CLJ_ENV=production lein ring server

brunobraga02:04:56

(get (System/getenv) "CLJ_ENV")
-> nil

noisesmith02:04:52

@brnbraga95: lein ring server starts two jvms - try using export so the child process sees the var

noisesmith02:04:46

also it's better to avoid using lein in production - it's a build tool

brunobraga02:04:01

yes, I am just testing, my plan is to write a script to test my apis, and send a enviroment variable so that I will know when I am testing and I can point my apis to a mocked database kind of thing (create a local datomic database)

brunobraga02:04:10

and hit it with posts and gets

brunobraga02:04:29

this script would also add all the schemas and delete the database after

dpsutton03:04:08

i'm a big fan of an edn or properties file that specifies all of this. and then your build infrastructure can swap out the correct one for production

dpsutton03:04:33

easy to read all necessary environment variables and the prod ones are never seen by people who don't have access to the build environment

dpsutton03:04:33

i know jenkins has a notion of a secrets file. i'd be surprised if most build tools did not as well

jrbrodie7704:04:54

Does anyone know if there's a figwheel config option that would cause the REPL utils to be available in all namespaces? Right now (doc my-func) doesn't work, I need to call (cljs.doc my-ns/my-func) Which is a bit tedious. Ideas?

mfikes04:04:19

@jrbrodie77 It would be interesting if doc, source, etc. could be optionally enabled as REPL specials (like in-ns) so they work everywhere. (They actually are REPL specials in Replete, which is really handy when messing around on an iOS device—but that’s nonstandard.)

mfikes04:04:41

There was a talk in which Stu Halloway discussed simply writing your own REPL features when you wanted them. I suspect this wouldn’t be too hard to do with Figwheel if you really wanted them to be REPL specials for your own use.

mfikes04:04:02

You could trivially change that code to do the same for doc and friends.

jrbrodie7704:04:02

Thanks @mfikes. This had got to catch a lot of beginners. It’s part of the ipython workflow (dir, help etc)

jrbrodie7704:04:36

I’ll check that out

mfikes04:04:40

Yeah, I usually just (require '[cljs.repl :refer [doc source]]) etc

brunobraga05:04:23

hey guys, so I am trying to automate my tests, and I am using the following function to mock my api: (mock/request :post (v :endpoint).. the second parameter can also be :get..do you guys know if can send this second param from another value ? just like I am doing with the third one I know that (mock/request "post" (v :endpoint) therefore using it as a string wont work

seancorfield05:04:15

@brnbraga95 assuming mock/request is a function (rather than a macro) then, yeah, sure you can pass the keyword dynamically.

seancorfield05:04:43

You can convert the "post" string to a keyword with (keyword "post")

thachmai07:04:26

hi guys, I'm trying to use hiccup as a templating engine to generate HTML

thachmai07:04:35

any tip on how I can inject raw html into hiccup?

thachmai08:04:35

never mind the above, seems like hiccup 1.0.5 doesn't escape HTML by default

timo12:04:15

Hi there, do I have to specify externs for every lib I get via cljsjs? Because I am getting an error that a function is not recognised when compiling with :advanced. This is the only extern that is specified in my luminus-project: :externs ["react/externs/react.js"]

timo12:04:21

Thing is: I am using leaflet from cljsjs and it runs fine in dev but in prod it tells me that Uncaught TypeError: L.$geoJSON$ is not a function. I activate debugging options. And in the supposed externs-file I was able to track down the corresponding function: https://github.com/cljsjs/packages/blob/master/leaflet/resources/cljsjs/leaflet/common/leaflet.ext.js#L811. From my understanding there shouldn't be a problem, right?

justinlee15:04:44

@U4GEXTNGZ the cljsjs builds are supposed to have externs

timo16:04:27

hey @lee.justin.m thanks so far. Is there a good manual on how to implement the libs from cljsjs into the build?

justinlee16:04:08

you are supposed to just include them like a normal cljs library

timo16:04:19

alright, so it should work then? Because I did that and somehow this error still comes up...

timo16:04:43

it's only the geoJSON-function...others are working

justinlee16:04:51

let’s jump back into #clojurescript because someone might be able to track this down.

agigao12:04:34

Hello Clojurians, I’m working through Clojure Applied and can someone please help me figure out this small snippet of code?

Chris Bidler12:04:35

so defrecord is defining, well, a “record”, which is storage for the described data elements and then implementations for any protocols you want to conform to

Chris Bidler12:04:55

so, you would instantiate a Money with one of two convenience fns that are created by the defrecord macro: ->Money or map->Money, like so: (def fat-stack (->Money 25 usd)) ;; assume that usd was defined as a Currency earlier

Chris Bidler12:04:37

or (def fatter-stack (map->Money {:amount 99 :currency eur})) ;; again, definition of eur is assumed

Chris Bidler12:04:02

and since the Money record conforms to Comparable you can do things like (sort [fatter-stack fat-stack])

Chris Bidler13:04:08

and inside sort somewhere is code that calls (compareTo fatter-stack fat-stack) to figure out their ordering, and at that point m1 and m2 are each bound to an instance of Money

Chris Bidler13:04:29

and finally, since m1 and m2 are Moneys, calling (:amount m1) and (:amount m2) fetches the amount that you provided when you created that Money record (in our example, calling (compareTo fatter-stack fat-stack) those would be 99 and 25, respectively)

👍 4
agigao13:04:35

Thank you Chris!

4
lgessler20:04:01

Is there a reason why I shouldn't get rid of the core after all my namespaces? For my purposes, at least, it seems like unnecessary clutter to have foo.bar.core when I could just have foo.bar, but I'm wondering if there's maybe something I hadn't considered. As a minor matter of aesthetics I suppose it might be pleasing to have foo.bar.core have the same number of dots as in foo.bar.utils, foo.bar.baz, etc., to reinforce the fact that these namespaces all ought to be considered as belonging to the same level of abstraction, but if that's all the matter is, then I think I could personally go the other way.

mfikes20:04:55

@lgessler One thing you want to at least do is ensure that your namespaces have 2 or more segments. So at least foo.core but not foo.

👍 4
Chris Bidler21:04:16

@lgessler I think it can also be convenient to have an explicitly-named namespace segment for just the stuff you need to AOT into .class files, though whether that is foo.bar.core or foo.bar.main (with a -main inside) is a matter of personal preference, when it’s not a matter of following the team or project style guide.

👍 4
lgessler21:04:26

those are two good reasons! thank you both

avfonarev21:04:42

I've just got a clean system and have to install Java. Will the latest version of Clojure work with Java 10?

jumar09:04:55

You'll likely have problems if you want to use it with Cider (especially refactor-nrepl: https://github.com/clojure-emacs/refactor-nrepl/issues/206)

schmee22:04:26

@avfonarev shouldn’t be a problem

schmee22:04:43

if it is, either make a ticket in jira or ask someone here to make one 🙂

avfonarev22:04:51

@schmee thanks. A silly question: I've always installed JDK. What will I loose if I get just JRE?

Alex Miller (Clojure team)22:04:50

The javac compiler and the jar tool are the biggest things you are likely to need