Fork me on GitHub
#beginners
<
2016-08-20
>
mfikes04:08:34

@dpsutton Alex’s assertion carries over to ClojureScript. Here is what that looks like with :repl-verbose enabled so you can see the JavaScript is the same:

cljs.user=> (let [x 1]
       #_=>  (let [y 2]
       #_=>   (+ x y)))
Evaluating Expression
(function (){var x = (1);
var y = (2);
return (x + y);
})()
3
cljs.user=> (let [x 1
       #_=>       y 2]
       #_=>  (+ x y))
Evaluating Expression
(function (){var x = (1);
var y = (2);
return (x + y);
})()
3

olegakbarov14:08:59

how do i load edn-file only on initialization of an application? more specifically — i want to serve a file on each request to my server, but see no reason to load it from disk on every req

plexus15:08:36

(def edn-contents (slurp ( "path/to/file.edn")))

(defn handler [req]
  {:status 200
   :body edn-contents})

plexus15:08:48

something like this

olegakbarov18:08:47

thanks! does edn-contents invoked only once?

plexus19:08:18

yeah, the (slurp ...) gets called when the app boots, and then the result is assigned to edn-contents for later reference