This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-14
Channels
- # aws (1)
- # bangalore-clj (1)
- # beginners (48)
- # boot (65)
- # braveandtrue (1)
- # cider (1)
- # clara (15)
- # cljs-dev (7)
- # clojure (179)
- # clojure-austin (1)
- # clojure-denmark (2)
- # clojure-greece (68)
- # clojure-italy (7)
- # clojure-russia (41)
- # clojure-serbia (9)
- # clojure-spec (44)
- # clojure-uk (27)
- # clojured (15)
- # clojureremote (20)
- # clojurescript (70)
- # community-development (2)
- # core-async (10)
- # cursive (14)
- # datomic (36)
- # defnpodcast (3)
- # emacs (13)
- # events (13)
- # hoplon (33)
- # immutant (18)
- # instaparse (2)
- # jobs (29)
- # jobs-discuss (71)
- # klipse (38)
- # lein-figwheel (4)
- # leiningen (1)
- # mount (34)
- # off-topic (36)
- # om (3)
- # onyx (51)
- # pedestal (5)
- # perun (8)
- # proton (2)
- # rdf (8)
- # re-frame (33)
- # reagent (24)
- # remote-jobs (1)
- # rum (6)
- # spacemacs (2)
- # specter (14)
- # sql (5)
- # testing (6)
- # untangled (1)
- # vim (10)
- # yada (3)
@arnout i've just noticed your mount-lite 2.0
.
do you have a public example app showcasing or i can only look at the test suite?
thanks, i will give it a try.
im just a bit worried how will it cooperate with boot-jetty
, boot-refresh
and the boot repl and running tests from cursive... 😕
for example when clojure.tools.namespace.repl/refresh
unloads changed namespaces, the states defined in them wont be stopped
i saw in the 0.2.0 docs that
> States are not automatically stopped anymore on redefinition.
however as i understand refresh
is not doing redefinition
True, stopping states is your own responsibility, especially with tools.namespace. With tests, it's quite easy to add a fixture that ensures all states are stopped after your tests have run (regardless of their results).
With tools.namespace it is possible to add metadata to the namespaces in order to have different refresh behaviour.
for tests i would just use separate sessions anyway probably since with cursive they are supposed to be run in the same repl as the dev process
im gonna try it soon, but i suspect this boot task won't cut it: https://github.com/samestep/boot-refresh/blob/master/src/samestep/boot_refresh.clj
according to https://github.com/clojure/tools.namespace i should do something like this:
(defn start []
(alter-var-root #'my-app (constantly (start-my-app))))
(defn restart []
(stop-my-app my-app)
(refresh :after 'dev/start))
so i guess it should replace the middle of the boot refresh task with
(mount/stop) (refresh :after 'mount.lite/start)
From the former 0.9.x
version docs:
> This cascading is great to work with, and in combination with the tools.namespace library it can really shine. Whenever you make sure your namespaces with defstate definitions have {:clojure.tools.namespace.repl/unload false} as metadata, calling (clojure.tools.namespace.repl/refresh :after 'mount.lite/start) will only stop the required states (in correct order) and restart them.
ok, thanks, i will play with it and report back with actual examples if something doesn't work
oh, i misread it... so the namespaces should be marked with unload, not the defstates...
Correct, if you use 0.9.x
. Otherwise, you are responsible for stop
ing the states beforehand.
but ctnr/refresh
doesn't seem to have a hook for that... =:-/
i dont want to use 0.9.x
; im strictly talking about 0.2.0
because i want independent states for tests within the same repl.
i don't see any other way how to make a convenient workflow in cursive otherwise.
@arnout do i see well that by default i can't define explicit dependencies between states, only by using mount.extensions.explicit-deps/start
?
i was wondering how can i put multiple defstates
into one namespace.
for example if i do
(ns app.datomic
(:require
[app.conf :refer [opts]]
...
(defstate uri
:start (:uri @opts))
(defstate conn
:start (do (println "Connecting to Datomic...")
(connect @uri))
...
i get this error:
clojure.lang.ExceptionInfo: state uri not started
name: "uri"
clojure.lang.ExceptionInfo: error while starting state #'app.datomic/conn
var: #'app.datomic/conn
which practically suggests that i should have 1 defstate
per namespace, unless they are not dependent on each other.
on https://github.com/aroemers/mount-lite you said > The order in which the states are started is determined by their load order by the Clojure compiler. which i understand it refers to the order of namespaces, but it would make sense to start the states in definition order? or it's actually not a realistic use-case, hence better not add more code to support it?
i thought the problem is solved by adding :dependencies [#'uri]
to the conn
state as i saw it in the mount.lite test suite, but after removing it, the problem is gone 😕
@onetom, indeed, by default the dependencies between the defstate
s are inferred by the Clojure compiler. So yes, the defstate
are started in definition order. Also, you are free to put as many defstate
s in one namespaces as you want, whether you use the explicit-deps
extension or not.
Hi @jorisbontje, long time no see 🙂