by emccue · 1y ago · 0 comments
(defprotocol Dog
:extend-via-metadata true
(bark [_]))When :extend-via-metadata is true, values can extend protocols by adding metadata where keys are fully-qualified protocol function symbols and values are function implementations. Protocol implementations are checked first for direct definitions (defrecord, deftype, reify), then metadata definitions, then external extensions (extend, extend-type, extend-protocol).
(def component (with-meta {:name "db"} {`start (constantly "started")})) (start component) ;;=> "started"
Kind of a crazy feature.