Immutable-js ClojureScript bindings

Hi,

I’m currently using draftjs to implement a text editor. draftjs uses immutable-js. I wonder if there is a lib out there that implements all relevant ClojureScript prototcols to work with immutable-js the same way like with ClojureScript’s own data structures?

I found this tweet from ClojureScript’s maintainer David Nolen:

That contains an example gist and describes immutable-js as a possible drop-in replacement for ClojureScript’s data structures.

I’ve also done some experiments with implementing the ILookup protocol:

  (extend-protocol ILookup
    immutable/Map
    (-lookup
      ([o k]
       (.get o
             (if (keyword? k)
               (name k)
               k)))
      ([o k not-found]
       (.get o
             (if (keyword? k)
               (name k)
               k)
             not-found))))

  (extend-protocol ILookup
    immutable/Record
    (-lookup
      ([o k]
       (.get o
             (if (keyword? k)
               (name k)
               k)))
      ([o k not-found]
       (.get o
             (if (keyword? k)
               (name k)
               k)
             not-found))))

It works fine. But maybe there is a lib out there that already implemented this?

Best regards,

Max

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.