Hi everyone, I wanted to find out what's the most idiomatic way to use component library. I have defined one component in a namespace
(defrecord IM-Proto-0
[status config state-component]
im.access/Access
component/Lifecycle
(start [component]
(-> component
(assoc :status :active)))
(stop [component]
(-> component
(assoc :status :deactive))))
(defmethod im.access/create
Type-ID
[config]
(-> {:config config}
(map->IM-Proto-0)))
And then in another where I am constructing the system I use the component this way - the im.access
for example is the namespace of the component record :
(defn create-system'
[{:keys [im-config
om-config
state-config]
:as master-config}]
(component/system-map
:im (-> (im.access/create im-config)
(component/using {:state-component :state}))
:om (-> (om.access/create om-config)
(component/using {:state-component :state}))
:state (-> (state.access/create state-config))))
I don't know if I am being too picky about this but the problem is this way it is not clear form where I want to construct the system that which components use which dependencies - let alone the fact that we actually might import this whole artifact somewhere else and allow for systems to be composed this way.
Is there a more idiomatic way to write components ? or am I being too picky about this ?
Thanks in advance@ho0man I'm not really sure what you're asking here...?
I'm also a bit confused about your IM-Proto-0
component since it has status
and state-component
fields but in your create
"constructor" function, you're passing in config
which isn't mentioned in IM-Proto-0
...