Fork me on GitHub
#mount
<
2016-07-20
>
jocrau01:07:39

@arnout: No. Waiting for the response (and using it as seed data) would be the intended behavior.

jocrau01:07:52

@tolitius: Thanks for your suggestion (BTW no need to explain why you didnโ€™t respond within 2 minutes ๐Ÿ˜‰. This is open-source development not the Comcastยฎ hotline ๐Ÿ˜œ ). Your solution mitigates one of the two problems: it binds the expected value to the state (it still has to be dereferenced twice, though). But the problem with dereferencing the state before the response arrives still exists.

tolitius01:07:36

@jocrau: so in clojure speak, you just want something like:

user=> (mount/in-cljc-mode)
:cljc
user=> (defstate meta-data :start (:body @(http/get "")))
#'user/meta-data
user=> @meta-data
"{\"ip\":\"10.23.42.110\",\"about\":\"/about\",\"Pro!\":\"\"}"
?

tolitius02:07:15

or closer to your channel example:

(defn cljs-http-get [url]
  (let [c (chan)]
    (go (>! c {:body "loaded meta data"}))
    c))

(defstate meta-data :start (-> (cljs-http-get "")
                               <!!
                               :body))

@meta-data
"loaded meta data"

tolitius02:07:09

here, at any time meta-data is derefed, it will wait (only for the first time) until it is loaded, and then would keep returning the value

richiardiandrea17:07:32

I have a question on cprop...when I set the conf property, do I still need to use csource/from-file or it does the load + merge automatically?

richiardiandrea17:07:12

my goal is to have a file outside the jar that can be slurped and merged at runtime

richiardiandrea17:07:49

ok I tried and the very nice error message shed some light:

Caused by: java.util.MissingResourceException: can't find a configuration file path: "/path/to/another.edn". besides providing it via "(load-config :file <path>)", it could also be set via "conf" system property (i.e. -Dconf=<path>)

tolitius18:07:58

@richiardiandrea: if the conf property is set, no need to use source/from-file unless you'd like another file to be merged (i.e. override the file under the conf property)

richiardiandrea18:07:27

great yes I gathered that from above, pretty neat ! ๐Ÿ˜„

tolitius18:07:57

ah, cool. so it works?

tolitius18:07:08

niice ๐Ÿ™‚

richiardiandrea18:07:50

and with this I merge some conf from a namespace as well:

(defn make-config
  "Creates a default configuration map"
  []
  (c/load-config :merge [env/defaults
                         {:version (if-let [version (version!)] version "0.0.0")}]))

(defstate
  config
  :start (make-config))

tolitius18:07:05

you can also have a config.edn in a classpath and not have to set anything at all

richiardiandrea18:07:09

and everything gets merged when I mount/start

richiardiandrea18:07:13

yes I have that as well

richiardiandrea18:07:24

cprop is in the foundation of lambone ๐Ÿ˜„

richiardiandrea18:07:41

so far it has been great, thanks a lot

tolitius18:07:11

sure, very welcome! glad it's useful ๐Ÿ™‚

richiardiandrea18:07:26

immensely ๐Ÿ™‚

tolitius18:07:51

yea lambone looks really nice, that's where you wanted to contribute boot support for luminus from, right?

richiardiandrea18:07:15

but it has developed as something a bit different

richiardiandrea18:07:42

for instance the assets are server from boot-serve, as separate process

richiardiandrea18:07:46

there are two repls

richiardiandrea18:07:16

I wanted to achieve complete isolation of the backend and frontend

richiardiandrea18:07:26

at the moment there is a problem with boot-cljs-devtools as I am pointing to a version not on Clojars

tolitius18:07:26

by two repls you mean one for clj one for cljs?

richiardiandrea18:07:46

yeah, because in the clj classpath I have only clj deps

richiardiandrea18:07:20

but the clj repl and cljs are in the same command (`boot dev`), i.e. one terminal only

richiardiandrea18:07:35

on two different ports though

tolitius18:07:16

right, depending on the flavor

tolitius18:07:56

ah.. both will be started by default, interesting

richiardiandrea18:07:08

well you can do boot dev -f backend in one terminal and boot dev -f frontend in another...but I usually boot dev and both start

tolitius18:07:39

and then another terminal with boot repl -c => (start-repl)?

richiardiandrea18:07:21

yes, I usually connect from within cider, some colleagues using Cursive...it depends on you ๐Ÿ˜„

richiardiandrea18:07:44

actually you need two clients

richiardiandrea18:07:56

so two boot repl -c in your case

richiardiandrea18:07:23

this is basically the part that differs from the other approaches

tolitius18:07:26

vim, but I don't do frontend often, so I feel a bit rusty at the cljs repl ๐Ÿ™‚

richiardiandrea18:07:13

in luminous you can potentially connect to a unique repl and switch between the two by doing :cljs/exit

richiardiandrea18:07:07

but all the deps are on the same classpath...I did not want that, I guess I had too many dependency clashes and I am a bit afraid of them ๐Ÿ˜„

tolitius18:07:06

right, I hear you. decoupling ftw ๐Ÿ™‚

richiardiandrea18:07:14

just my view, but didn't want to push it to luminous as it is kind of different from it as of now

tolitius18:07:15

right, makes sense. I am glad both exist thought, having a choice is good in this case