You know in the example, on the github project page, it has (defmethod ig/init-key :adapter/jetty [_ {:keys [handler] :as opts}]
and (defmethod ig/init-key :handler/greet [_ {:keys [name]}]
I can see where the keys
part works, but why the don't care
placeholder, i.e., _
What would go there?
You could just print it out
Yeah, good idea.
it's the key name
or rather, the multimethod dispatch value
so, in the example above (first one), if _
is replaced with foo
and then a (println foo
), the output will be :adapter/jetty
IIRC it will be the argument the method is called with
Or rather the arguments
(defmulti ex (fn[x y] (:a x)))
(defmethod ex 2 [x y] (prn 2 x y))
(ex {:a 2 :b 3} {:d 123})
=> 2 {:a 2, :b 3} {:d 123}
ta 🙂
Quite new to this, but if I wanted to share the integrant initialised "system" (by calling (ig/init! config)
) an approach would be to store that system
in an atom (say my core
namespace) then refer to that atom in each of my other namespaces to then obtain the values required (in the other namespace?)
I think the purpose of integrant is to make untangling and encapsulation of a system easier. I think if you need to get something from running system then you, probably, should think twice. But if you really need, you could peek into https://github.com/weavejester/integrant-repl/blob/89a9552fd3623976b83318a5f8f903f1ebeda2f7/src/integrant/repl.clj#L47
Thank you. I'll have a ponder 🙂