I am trying to expand the DomKM / silk library.
In particular, there is a deftype Route that implements the Pattern protocol, which has implementation methods that I would like to use in my custom implementation of the Pattern protocol.
https://github.com/DomKM/silk/blob/master/src/domkm/silk.cljx#L355
(deftype Route [name pattern] Pattern (-match [this -url] (when-let [params (match pattern (url -url))] (assoc params ::name name ::pattern pattern))) (-unmatch [this params] (->> (dissoc params ::name ::pattern) (unmatch pattern) url)) (-match-validator [_] map?) (-unmatch-validators [_] {}))
Ok, so my implementation would look like this, but I would like to inherit Route methods. I mean, to execute some user logic first, and then pass it to the original Route methods.
(deftype MyRoute [name pattern] silk/Pattern (-match [this -url] true) ;match logic here (-unmatch [this {nm ::name :as params}] true) ;unmatch logic here (-match-validator [_] map?) (-unmatch-validators [_] {}))
How is this done in clojure / clojurescript?
source share