Fork me on GitHub

Good Morning!


I know nothing about extend via metadata


i think i've used :extend-via-metadata only once, when i had an existing protocol-based codebase and needed to dynamically compose some components to satisfy a protocol... my recollection is that :extend-via-metadata made life a lot easier, but i was never faced with the "or use a multimethod" choice because existing codebase


My interpretation is :extend-via-metadata is useful for libraries (that look for that) and/or tooling.


The nice thing about :extend-via-metadata is that you can provide implementations on an ad hoc basis, just by attaching metadata to a Clojure object. This is common with datafy/`nav` for example, and we do it with Component at work quite a bit (attaching start/`stop` implementations to hash maps or functions, instead of using defrecord for some lifecycle).


So you don't need to define anything, no defrecord, no defmethod.