This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-05
Channels
- # adventofcode (41)
- # bangalore-clj (4)
- # beginners (283)
- # boot (62)
- # clara (9)
- # cljsrn (3)
- # clojure (112)
- # clojure-brasil (1)
- # clojure-greece (1)
- # clojure-korea (6)
- # clojure-russia (99)
- # clojure-spec (29)
- # clojure-uk (12)
- # clojurescript (34)
- # clojurex (5)
- # core-logic (1)
- # cursive (31)
- # datomic (30)
- # devcards (5)
- # editors (19)
- # emacs (31)
- # events (5)
- # garden (4)
- # hoplon (137)
- # lein-figwheel (3)
- # luminus (4)
- # mount (7)
- # off-topic (7)
- # om (18)
- # om-next (3)
- # onyx (88)
- # proton (1)
- # protorepl (6)
- # re-frame (48)
- # reagent (15)
- # spacemacs (41)
- # testing (1)
- # untangled (2)
- # yada (18)
Love the addition of (find-all-states)
and (running-states)
. I'm going to start using the latter inside use-fixtures
so that I can return the app state back to what it was before tests were run.
Is it possible to have binding
style semantics in mount?
If I have this:
(defstate db
:start (start-db config)
:stop (stop-db db))
(defn insert-into-db
[table row]
(jdbc/insert! db table row))
Then I want to wrap my database calls in a transaction:
(jdbc/with-db-transaction [conn db]
(binding [db conn]
(insert-into-db :things {:id 1 :name "first thing"})
(insert-into-db :things {:id 2 :name "second thing"})))
How do I do this sort of thing with mount? Or is there a better approach to this sort of problem?@mnewt you could use a dynamic var, e.g:
(defstate ^:dynamic *conn*
:start (connect!)
:stop (disconnect! *conn*))
this is how I end up doing it in the conman lib for luminus https://github.com/luminus-framework/conman/blob/master/src/conman/core.clj#L88