Fork me on GitHub
#mount
<
2016-07-18
>
arnout10:07:50

@jocrau: would it be a problem if other states would have to wait before the response has been received, when starting?

tolitius14:07:08

@jocrau: was out for a couple of days.. would something like this work for you:

(defstate seed-data :start (let [data (atom :empty)]
                             (http/get "" {} (fn [{:keys [body]}]
                                                                 (reset! data body))
                             data)))

tolitius14:07:46

in case you are in cljc mode (for clojurescript), you would have to deref it twice to get the value (since data is an atom):

=> @@seed-data
"{\"ip\":\"10.23.42.110\",\"about\":\"/about\",\"Pro!\":\"\"}"

tolitius14:07:20

here http/get takes a callback, but you can do the same thing with a channel