Fork me on GitHub
#cljs-dev
<
2021-12-29
>
lilactown17:12:07

I'm running into the same issue: I'd like to extend a protocol to all maps, sets and sequential data types, but it doesn't seem to work like in Clojure, where I can extend IPersistentSet IPersistentMap and Sequential and call it a day

lilactown17:12:29

it seems like I have to extend my protocol to each concrete type in CLJS

lilactown17:12:22

I understand this is probably a function of JS' object model + trying to keep protocol lookups efficient

emccue18:12:48

if you control the protocol - take every method in the protocol and change it from method to method*

emccue18:12:41

(defn method [o]
  (cond
    (map? o)
    (map-impl o)

    (set? o)
    (set-impl o)

    (sequential? o)
    (sequential-impl o)

    :else
    (method* o)))

emccue18:12:57

then you have the ability to do a more complex dispatch