Closed clyfe closed 4 years ago
I just noticed the resolve-key
multi-method in 0.8.0-alpha, which can be used to bring the key into the output; nevertheless, the notes above are still desirable to have.
Knowing the key can be useful (think handler registration).
Can you explain your use-case further?
In the config map I want to have:
Outcome in the system map:
:k
handles events named :k
:k
I have the handler fn and not some complication like {:ev :k :fn h}
Something along these lines:
;; ns registry
(derive ::handler :module/const)
(defn register [[k v]]
#_(... register v to handle events named k))
(defmethod ig/init-key ::handlers [_ handlers]
(run! register handlers)
handlers)
;; ns my.handlers
(defn foo ...)
(defn bar ...)
(derive ::foo ::registry/handler)
(derive ::bar ::registry/handler)
(def config {::foo foo
::bar bar
::registry/handlers (ig/refmap ::registry/handler)})
RefLike protocol was extended. RefMap construct was not accepted into the core. Standalone RefMap implementation based on the extended RefLike protocol is here: https://github.com/tape-framework/refmap
RefMap
would be likeRefSet
but would resolve to a map{k -> ref}
instead a refs set. Knowing the key can be useful (think handler registration). Alternatively, extend theRefLike
protocol with aresolve
method and inexpand-key
postwalk the config via it, this would allow customRefThing
s. Sample: