mount

jocrau 2016-07-20T01:03:39.000063Z

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

jocrau 2016-07-20T01:16:52.000064Z

@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.

tolitius 2016-07-20T01:54:36.000065Z

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

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

tolitius 2016-07-20T02:47:15.000066Z

or closer to your channel example:

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

(defstate meta-data :start (-&gt; (cljs-http-get "<http://www.xyz.com/meta-data>")
                               &lt;!!
                               :body))

@meta-data
"loaded meta data"

tolitius 2016-07-20T02:50:09.000069Z

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

richiardiandrea 2016-07-20T17:55:32.000078Z

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?

richiardiandrea 2016-07-20T17:55:47.000079Z

talking about this: https://github.com/tolitius/cprop#setting-the-conf-system-property

richiardiandrea 2016-07-20T17:56:12.000081Z

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

richiardiandrea 2016-07-20T17:59:49.000083Z

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 &lt;path&gt;)", it could also be set via "conf" system property (i.e. -Dconf=&lt;path&gt;)

tolitius 2016-07-20T18:21:58.000084Z

@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)

richiardiandrea 2016-07-20T18:22:27.000085Z

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

tolitius 2016-07-20T18:22:57.000087Z

ah, cool. so it works?

richiardiandrea 2016-07-20T18:23:01.000088Z

yeah

tolitius 2016-07-20T18:23:08.000089Z

niice ๐Ÿ™‚

richiardiandrea 2016-07-20T18:23:50.000090Z

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))

tolitius 2016-07-20T18:24:05.000091Z

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

richiardiandrea 2016-07-20T18:24:09.000092Z

and everything gets merged when I mount/start

richiardiandrea 2016-07-20T18:24:13.000093Z

yes I have that as well

richiardiandrea 2016-07-20T18:24:24.000094Z

cprop is in the foundation of lambone ๐Ÿ˜„

richiardiandrea 2016-07-20T18:24:41.000095Z

so far it has been great, thanks a lot

tolitius 2016-07-20T18:25:11.000096Z

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

richiardiandrea 2016-07-20T18:25:26.000097Z

immensely ๐Ÿ™‚

tolitius 2016-07-20T18:28:51.000098Z

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

richiardiandrea 2016-07-20T18:28:59.000100Z

yeah

richiardiandrea 2016-07-20T18:29:15.000101Z

but it has developed as something a bit different

richiardiandrea 2016-07-20T18:29:42.000103Z

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

richiardiandrea 2016-07-20T18:29:46.000104Z

there are two repls

richiardiandrea 2016-07-20T18:30:16.000105Z

I wanted to achieve complete isolation of the backend and frontend

richiardiandrea 2016-07-20T18:30:26.000106Z

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

tolitius 2016-07-20T18:32:13.000108Z

yea, I read https://github.com/Lambda-X/lambone/blob/master/resources/leiningen/new/lambone/common/build.boot before, definitely well organized

tolitius 2016-07-20T18:32:26.000110Z

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

richiardiandrea 2016-07-20T18:32:46.000111Z

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

richiardiandrea 2016-07-20T18:33:20.000112Z

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

richiardiandrea 2016-07-20T18:33:35.000113Z

on two different ports though

tolitius 2016-07-20T18:35:16.000114Z

right, depending on the flavor

tolitius 2016-07-20T18:35:56.000115Z

ah.. both will be started by default, interesting

richiardiandrea 2016-07-20T18:36:08.000116Z

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

richiardiandrea 2016-07-20T18:36:10.000117Z

yeah

tolitius 2016-07-20T18:36:39.000118Z

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

richiardiandrea 2016-07-20T18:37:21.000119Z

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

richiardiandrea 2016-07-20T18:37:44.000120Z

actually you need two clients

richiardiandrea 2016-07-20T18:37:56.000121Z

so two boot repl -c in your case

richiardiandrea 2016-07-20T18:38:23.000122Z

this is basically the part that differs from the other approaches

tolitius 2016-07-20T18:38:26.000123Z

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

richiardiandrea 2016-07-20T18:39:13.000125Z

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

richiardiandrea 2016-07-20T18:40:07.000126Z

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 ๐Ÿ˜„

tolitius 2016-07-20T18:41:06.000127Z

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

richiardiandrea 2016-07-20T18:41:12.000128Z

ah ah

richiardiandrea 2016-07-20T18:42:14.000129Z

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

tolitius 2016-07-20T18:48:15.000130Z

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

richiardiandrea 2016-07-20T18:48:23.000131Z

yeah true that