Fork me on GitHub
#beginners
<
2018-03-14
>
mfikes00:03:11

@tkjone Thanks for trying out 1.10.x. You can tell the browser REPL to look for static content in your resources directory by passing :static-dir as a REPL option:

clj --main cljs.main --output-dir out --repl-opts '{:static-dir ["." "out" "resources"]}' --repl -h

mfikes00:03:26

This is currently not documented on http://clojurescript.org, but we have a PR in flight to document the browser REPL options https://github.com/mfikes/clojurescript-site/blob/issue-187/content/reference/repl-options.adoc#static-dir

athomasoriginal00:03:33

Awesome. I was just looking for that piece of documentation haha

mfikes00:03:51

Notice that I also passed --output-dir because in resources/index.html it has

<script src="out/main.js" type="text/javascript"></script>

athomasoriginal00:03:10

Yeah, I trying to understand that. Is it possible to define '{:static-dir ["." "out" "resources"]}' in the deps.edn file...or maybe I am misunderstanding the relationship between the cli tool and the deps.edn

Michael Fiano00:03:34

Is braveclojure a good place to start if one is already very familiar with Lisp?

mfikes00:03:45

No... deps.edn is only for managing dependencies and classpath

noisesmith00:03:07

@mfiano: if you already know lisp well, you might like "Joy of Clojure" - one of the best books out there

Michael Fiano00:03:35

@noisesmith Thanks. I've been using Common Lisp daily for the past 10 years. I am totally new to Clojure and even the JVM though.

noisesmith00:03:44

they are very different books though - brave and true is cute and fun, joc is difficult and accurate

noisesmith00:03:07

that is pretty much who joc is for I think - an experienced lisper learning a new lisp offshoot

Michael Fiano00:03:36

I spent all day setting up emacs/cider/lein after some snags. ready to start learning now

Michael Fiano00:03:15

Thanks for the advice. I'll check it out

athomasoriginal00:03:44

@mfikes is it planned that when one wants to add to --repl-opts one should specify it inline, or is there an alternative?

athomasoriginal00:03:46

It also seems like I can omit the --output-dir out part of the command. I tested with clj --main cljs.main --repl-opts '{:static-dir ["." "out" "resources"]}' --watch src --compile drumkit.core --repl and that works. Seems like --output-dir is defaulting to out

dum3ng00:03:34

I have some question on om.next

dum3ng00:03:42

If I wrote a ui like above, then I would expect MyComponent to be a component, like in react. But when I use (om/component? MyComponent), the result is false.

dum3ng00:03:18

Seems the function om/component? would only return true for an instance

noisesmith00:03:55

right, MyComponent is not a prototype, it's a class you can instantiate

noisesmith00:03:27

(if I recall correctly)

mfikes00:03:32

@tkjone I'm not aware of a plan to support REPL opts outside of the --repl-opts flag. Since you are passing --compile without also specifying --output-dir, it is defaulting to out

athomasoriginal00:03:50

I also have <audio data-key="65" src="sounds/clap.wav"></audio> files inside of the resources dir. Seems like they are not being found by the index.html

athomasoriginal00:03:09

which is odd because my css files are being found

dum3ng00:03:22

@noisesmith and (om/component? MyComponent) is false, is it expected?

athomasoriginal00:03:51

the structure of the resources looks like this:

├── resources
│   ├── css
│   └── sounds

noisesmith00:03:53

that’s what I’d expect, as it’s not a component, it’s a class, of which an instance would be a component

dum3ng00:03:32

ah I see. Thanks.

mfikes00:03:58

@tkjone This might be a consequence of .wav not being listed here https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/repl/browser.clj#L31 But I don't have much experience using the browser REPL for actual work. If you are curious, making a change to add that and building the compiler isn't too difficult: https://clojurescript.org/community/building

mfikes00:03:05

You could even add some print statements to the sent-static function in that file to try to sort out what it is doing for your .wav files

Drew Verlee03:03:40

Can someone explain this? If all the references are removed, why is it “hard to clean up” what is hard to clean? > There’s s a pitfall to hot code reloading however— any thread alive at the time of reloading will keep references to the old code until terminated. The problem is amplified by the fact that all references to these threads are wiped by the time reloading is complete, making it really tricky to clean the messed state up. Fortunately, Stuart Sierra came up with what has been dubbed Reloaded Workflow.

arrdem04:03:37

@drewverlee If all the references are actually cleaned up, then the Java garbage collector can do its thing and remove the object. Unfortunately, ensuring that you aren't retaining any references can be difficult. The "Reloaded Workflow" is a set of patterns for ensuring that you always have layers of indirection between your application code and its configuration state which makes it easy to "reload" your configuration without restarting the application (or just your REPL) entirely.

fmn10:03:06

Hi, how do you actually use clojure.spec to validate input and output of a function without actually touching the function? AFAIK, I should use fdef but unfortunately it only validates the args key (not sure about this). So is currently the best way, for pure validation, is using :pre and :post ?

fmn12:03:02

@christian767 This looks great. Thanks!

Vincent Cantin16:03:02

Hi, I don't understand this syntax, could someone explain why there is a ( before the get and the send? (. app (get "/hello" (fn [req res] (. res (send "Hello world"))))) source: https://medium.com/front-end-hacking/node-js-to-clojure-in-60-seconds-a996e0969471

Vincent Cantin23:03:07

Thank you. I was looking at another reference page which did not show that form, probably an outdated one.