@arnout: No. Waiting for the response (and using it as seed data) would be the intended behavior.
@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.
@jocrau: so in clojure speak, you just want something like:
user=> (mount/in-cljc-mode)
:cljc
user=> (defstate meta-data :start (:body @(http/get "<http://jsonip.com/>")))
#'user/meta-data
user=> @meta-data
"{\"ip\":\"10.23.42.110\",\"about\":\"/about\",\"Pro!\":\"<http://getjsonip.com>\"}"
?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 "<http://www.xyz.com/meta-data>")
<!!
:body))
@meta-data
"loaded meta data"
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
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?
talking about this: https://github.com/tolitius/cprop#setting-the-conf-system-property
my goal is to have a file outside the jar that can be slurped and merged at runtime
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>)
@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)
great yes I gathered that from above, pretty neat ! ๐
ah, cool. so it works?
yeah
niice ๐
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))
you can also have a config.edn
in a classpath and not have to set anything at all
and everything gets merged when I mount/start
yes I have that as well
cprop
is in the foundation of lambone
๐
so far it has been great, thanks a lot
sure, very welcome! glad it's useful ๐
immensely ๐
yea lambone
looks really nice, that's where you wanted to contribute boot support for luminus
from, right?
yeah
but it has developed as something a bit different
for instance the assets are server from boot-serve
, as separate process
there are two repls
I wanted to achieve complete isolation of the backend and frontend
at the moment there is a problem with boot-cljs-devtools
as I am pointing to a version not on Clojars
yea, I read https://github.com/Lambda-X/lambone/blob/master/resources/leiningen/new/lambone/common/build.boot before, definitely well organized
by two repls you mean one for clj one for cljs?
yeah, because in the clj classpath I have only clj deps
but the clj repl and cljs are in the same command (`boot dev`), i.e. one terminal only
on two different ports though
right, depending on the flavor
ah.. both will be started by default, interesting
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
yeah
and then another terminal with boot repl -c
=> (start-repl)
?
yes, I usually connect from within cider, some colleagues using Cursive...it depends on you ๐
actually you need two clients
so two boot repl -c
in your case
this is basically the part that differs from the other approaches
vim, but I don't do frontend often, so I feel a bit rusty at the cljs repl ๐
in luminous you can potentially connect to a unique repl and switch between the two by doing :cljs/exit
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 ๐
right, I hear you. decoupling ftw ๐
ah ah
just my view, but didn't want to push it to luminous as it is kind of different from it as of now
right, makes sense. I am glad both exist thought, having a choice is good in this case
yeah true that