To halt-key!
a particular thing, I think I need to have access to the big handler map, but halt-key!
is only passed a key and a value. IIUC, it's passed its own key, and the return value of init-key.
What do you mean by “big handler map”?
(defmethod ig/init-key :runners [_ {:keys [handler] :as opts}]
(runners/start-one-run-after-another handler))
i'm using lambdacd
for a little spike. the second param in that declaration is the desired thing.i'd love to know the domain term for that!
The configuration value is what I usually call it.
And the output from ig/init-key
is the initiated value
oh wait. I could write something like:
(defmethod ig/init-key :runners [_ {:keys [handler] :as opts}]
(runners/start-one-run-after-another handler)
handler)
(defmethod ig/init-key :this.needs.to.be.namespaced/runners [_ {:keys [handler] :as opts}]
{:runners (runners/start-one-run-after-another handler))
:handler handler})
(defmethod ig/halt-key :this.needs.to.be.namespaced/runners [_ {:keys [handler]}]
(runners/stop handler))
Right 🙂
but of course! makes sense. thanks so much
Typically the return value from ig/init-key
should contain everything you keep to clean up after itself.
Also it’s a good idea to namespace your keys, as unnamespaced keys can’t be inherited from.
oh ok, neat