This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-14
Channels
- # aatree (1)
- # admin-announcements (1)
- # beginners (12)
- # boot (359)
- # cljs-dev (23)
- # cljsjs (2)
- # cljsrn (1)
- # clojure (53)
- # clojure-czech (5)
- # clojure-madison (1)
- # clojure-russia (15)
- # clojured (8)
- # clojurescript (16)
- # community-development (2)
- # core-async (6)
- # cursive (19)
- # datomic (31)
- # emacs (48)
- # euroclojure (3)
- # hoplon (29)
- # microservices (7)
- # mount (46)
- # off-topic (7)
- # om (11)
- # proton (74)
- # reagent (4)
- # spacemacs (3)
@tolitius (or anyone interested), I am curious to know your opinion on https://github.com/aroemers/mount-lite/pull/5
hm, that seems like syntactic sugar on top of
(def ^dynamic *i* 10)
(defstate incrementer
:start (let [i *i*] (fn [n] (+ n i)))
:stop ...)
(with-redefs [*i* 20]
(mount/start))
am I missing anything? Doesn't seem all that usefulNo, that would not work, if the with-redefs
in your example is done in another thread than where the the :start
expression is executed.
Hmm, yes. Would be more stateful though, requiring an extra (global!) var and remembering to reset it after a (stop)
.
IMHO neither component, nor mount should be present in libraries (except for an optional integration)
Hi there, I have a (maybe simple minded) question on mount usage with regard to substitutions
I'm starting from the point of view that I might want to change behavior when I substitute some state, in particular for testing purposes
you substitute your state with something that you control, right? Something that would change the behaviour based on what you need in the test? E.g. mock database connection instead of a real one.
yes, e.g. my real db connection would be to a mongo db, but the mock db would then need quite different implementations
so, the real db has a "find-docs" function and the mock one, too, but obviously with quite different behavior (e.g. using atoms for the data storage)
the functions in the NS, as seemingly you're not testing the mongo implementation but the things that use it
just to explain a bit, the send-sms example on the mount homepage was throwing me off a little
the substituted state looks like a normal object to be used by some function, whereas the substitute is a function
@schaueho: Using a UserDb
protocol as @dm3 suggests would be the way to go. The issue you describe is not solved by either component or mount. Protocols solve your issue, and are still a good thing Mount still lets you use protocols, but you don't have to (as with Component you easily fall in the trap of putting everything in a protocol).