This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-14
Channels
- # admin-announcements (5)
- # aws (3)
- # beginners (35)
- # boot (96)
- # cider (1)
- # clara (6)
- # cljs-dev (12)
- # cljsrn (34)
- # clojure (151)
- # clojure-boston (3)
- # clojure-brasil (4)
- # clojure-canada (1)
- # clojure-czech (8)
- # clojure-dusseldorf (11)
- # clojure-japan (5)
- # clojure-russia (120)
- # clojure-taiwan (1)
- # clojure-uk (3)
- # clojurescript (7)
- # component (27)
- # cursive (13)
- # data-science (45)
- # datomic (1)
- # devcards (5)
- # emacs (3)
- # funcool (65)
- # hoplon (103)
- # instaparse (3)
- # jobs (14)
- # jobs-discuss (1)
- # juxt (2)
- # lein-figwheel (2)
- # off-topic (16)
- # om (20)
- # onyx (49)
- # parinfer (17)
- # perun (1)
- # planck (5)
- # proton (4)
- # re-frame (14)
- # ring-swagger (4)
- # spacemacs (4)
- # untangled (110)
- # yada (14)
hello, I have a system which contains two subsystems as children.. i’d ideally like to pass a common ‘database’ component to both subsystems, which those subsystems will pass into the components they contain.. is there a recommended way to handle that?
@keeth: Not sure if I understand your question correctly, but I pass my db like this: https://github.com/sveri/closp/blob/master/resources/leiningen/new/closp/clj/components/components.clj you can see the config component passed to two different components. AFAIU you can compose them as you want.
@sveri: thanks the main thing i am trying to avoid is the component being started and stopped more than once
i think i have a solution, producing a System implementation that allows to exclude certain components from being started and stopped by the system
thankfully component/(start|stop)-system lets you override the keys to be stopped/started, so i don’t have to re-implement too much of system
@keeth: Yea, the thing is, if you cannot restart a component n times, it is not a component anymore (thats my understanding, others may see this different). So you need to find a different solution to it. Out of interest, what is it that cannot be restarted?
it’s not that it can’t be restarted, but if I pass it to two different subsystems as dependencies, (.start db) will be called twice when the app starts up
I dont grok fully yet what you are doing. But a component, should only be started once, no matter to how many other components you pass it to. Maybe I dont understand what subsystem
is in your case?
so at app start, the top-level/parent system should start the db, and inject it into the child systems, and start the child systems after starting the db
but even tho the child systems will have a :database key in their system maps, i don’t want them to try starting it
I am not sure that component supports that, would be interesting to hear what @stuartsierra has to say about it.
see snippet above, i’m made a thin system implementation that allows me to exclude a set of keys of components which i do not want the system to start or stop
usage is something like:
(system/system-map-excluding
{:component1 (component/using (new-component-1) [:database])}
#{:database})
Nested systems are complicated and usually unnecessary; I recommend against them.